Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

Overriding of QWidget::event not working!!

$
0
0
Hey there, i am trying to override the default behavoiur of QWidget::event. I am trying to implement some touch features. On my widget i made sure to set setAttribute(Qt::WA_AcceptTouchEvents); Now from the docs, i read that Qt generates for the first non-primary touchpoint also a mouse event. I am simply trying to avoid this. I am using a default example of QT. You can find it in the example/touch directory shipped with QT. Here is my Code. Note that i am not calling the default behaviour of QWidget. I accept all touchevents and return true so clarify that i have handled the touchevent.     bool ScribbleArea::event(QEvent *event)     {         bool handleEvent = false;         QInputEvent* inPut = dynamic_cast<QInputEvent*>(event);         if(inPut)         {         switch (inPut ->type())         {             case QEvent::TouchBegin:             std::cout<<"ScribbleArea received TouchEvent BEGIN";             inPut->accept();             handleEvent=true;             break;             case QEvent::TouchUpdate:             //std::cout<<"ScribbleArea received TouchEvent UPDATE";             inPut->accept();             handleEvent=true;             break;             case QEvent::TouchEnd:             std::cout<<"ScribbleArea received TouchEvent END";             inPut->accept();             handleEvent=true;             break;             case QEvent::MouseButtonPress:             std::cout<<"ScribbleArea received MouseEvent PRESS";             break;             case QEvent::MouseButtonRelease:             std::cout<<"ScribbleArea received MouseEvent RELEASE";             break;     }         return handleEvent;     }     return true; } However, what i get is this, when i am simply touching the screen once. Why is this? I dont want the mouse event to be generated by QT. std::cout<<"ScribbleArea received TouchEvent"; std::cout<<"ScribbleArea received MouseEvent PRESS"; std::cout<<"ScribbleArea received TouchEvent END"; std::cout<<"ScribbleArea received MouseEvent RELEASE"; Thanks so far.

Viewing all articles
Browse latest Browse all 18427

Trending Articles