0

I want to get TouchEvent in Qt, but the program doesn't work, could you help me? And my OS is Ubuntu 14.04 and Win7, Qt library is 4.8.6, Qt creator is 3.2.1. Thank you.

MyMainWindow::MyMainWindow(QWidget *parent) :
    QMainWindow(parent)
{
    _uicls::setupUi(this);
    setAttribute(Qt::WA_AcceptTouchEvents);            // has setAttribute
}

bool MyMainWindow::event(QEvent *evt)
{
    qDebug()<<evt->type();                            // can't get TouchEvent
    switch(evt->type())
    {
    case QEvent::TouchBegin:
        qDebug()<<"touch Begin";
        evt->accept();
        return true;
    case QEvent::TouchUpdate:
        qDebug()<<"touch update";
        return true;
    case QEvent::TouchEnd:
        qDebug()<<"touch end";
    default:
        return _basecls::event(evt);
    }
}
liuyuedeyu
  • 13
  • 4
  • Is your main window the "top" layer? Have you tried `setAttribute(Qt::WA_StaticContents);` along with the other attribute setting? Either way, it might be a bug in Qt 4. – László Papp Nov 02 '14 at 08:16
  • First, I only have one MainWindow in my program. Second, I add setAttribute(Qt::WA_StaticContents); in my constructor, but it doesn't work yet. And whar are you say "the other attribute setting" ? Thank you very much. – liuyuedeyu Nov 02 '14 at 08:24

0 Answers0