Unsolved Why QT doesn't see all clicks?
-
Hello,
I have a QWidget ( myClass ) and when I click on it I would like to exec qDialog. Everything works, but when I click two times in a row fast, I go only once to mousePressEvent. My code:
void myClass::mousePressEvent(QMouseEvent *event) // I click on this widget { qInfo()<<"CLICK!"; QPoint global = mapToGlobal( QPoint(0,0) ); // this and next line only set position dialog->setGeometry( global.x(), global.y()+height(), 500, 500 ); dialog->exec(); }
When I click fast two Times I get:
"CLICK!"When I click two times in a normal speed ( 1 per second ) I get:
"CLICK!"
"CLICK!"When I delete line:
dialog->exec();
I can clicked very fast and everything works perfect. So exec() is very expensive.
Is there a way to use exec() and can clicked fast and get all "CLICK!"?
EDIT:
When I change exec() to show() result is the same: I don't see all clicks when click fast -
@TomNow99 Because dialog->exec() is a blocking call which blocks the event loop...
Use show() instead of exec(). -
@jsulm Thank you! But look at my EDIT ( I have to added it when you wrote your post )
-
@TomNow99 Then I think the second click does not arrive the widget anymore as the dialog is being shown.
What happens if you use show() wait until dialog is shown move it away from that widget and then click the widget to times fast? -
@jsulm I can't move dialog because it is Qt::FramelessWindowHint and Qt::Window and Qt::Popup.
-
@TomNow99 said in Why QT doesn't see all clicks?:
but when I click two times in a row fast,
Have you tried using mouseDoubleClickEvent() event handler?