I am overriden QGraphicsScene
and overload 2 methods: mouseDoubleClickEvent
and mouseReleaseEvent
. I want different logic executing on
For the logic that you want to occur on a double click, put the code inside mouseDoubleClickEvent()
and for the logic that you want to occur on a mouse release, put the code inside mouseReleaseEvent()
.
If you want to do something when the user clicks but doesn't double click, you have to wait to see if they click twice or not. On the first mouse release start a 200ms timer.
If you get a mouseDoubleClickEvent()
before the timer expires then it was a double click and you can do the double click logic. If the timer expires before you get another mouseDoubleClick()
then you know it was a single click.
Pseudocode
main()
{
connect(timer, SIGNAL(timeout()), this, SLOT(singleClick()));
}
mouseReleaseEvent()
{
timer->start();
}
mouseDoubleClickEvent()
{
timer->stop();
}
singleClick()
{
// Do single click behavior
}
This answer gives a rather similar solution.