C++ Qt未接收Q手势事件
我一直在尝试在Qt上获取手势事件,但我的程序只在我与它交互时识别鼠标事件 这是我编写的示例代码:C++ Qt未接收Q手势事件,c++,qt,C++,Qt,我一直在尝试在Qt上获取手势事件,但我的程序只在我与它交互时识别鼠标事件 这是我编写的示例代码: MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); grabGesture(Qt::SwipeGesture); } bool MainWindow::event(QEvent *e){
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
grabGesture(Qt::SwipeGesture);
}
bool MainWindow::event(QEvent *e){
if (e->type() == QEvent::Gesture) {
std::cout << "got a gesture" << std::endl;
}
return QWidget::event(e);
}
MainWindow::MainWindow(QWidget*父项):
QMainWindow(父级),
用户界面(新用户界面::主窗口)
{
用户界面->设置用户界面(此);
抓取手势(Qt::SwipeGesture);
}
bool主窗口::事件(QEvent*e){
如果(e->type()==QEvent::手势){
std::无法尝试设置setAttribute(Qt::WA_AcceptTouchEvents);
只是尝试了一下,但不幸的是没有成功。