PDA

View Full Version : Mouse event with some delay



vivek.panchal
22nd August 2012, 13:31
-hi,

i am making an one class(say my_class) which inherited QPushButton class.... i want to custmize events pass to my_class object...
when i press that button it will generate press and show button image of pressbutton.jpg from style sheet but after some time it will generate release event and show button image of releasebutton.jpg from style sheet..

i want press button and release button event with customizations.... means first press event got update button image and after some time release event generates and image changes back to ideal states.

Naahmi
22nd August 2012, 19:25
You can use Qtimer for a delay.

StrikeByte
22nd August 2012, 21:20
You will have to overwrite mousePressEvent ( QMouseEvent * e ) and mouseReleaseEvent ( QMouseEvent * e )
and add a timer to the mousePressEvent when the timer (QTimer::singleshot) timesout you can send a mouseRelease event by using QApplication::sendEvent(QObject *receiver, QEvent *event); or QApplication::postEvent(QObject *receiver, QEvent *event, int prio)