Distinguish between single and double click events in Qt

后端 未结 3 1634
Happy的楠姐
Happy的楠姐 2020-11-30 12:25

I have a QAbstractItemView that needs to react to single and double click events. The actions are different depending on whether it was single clicked or double

3条回答
  •  心在旅途
    2020-11-30 12:53

    You can find answer in the thread titled Double Click Capturing on QtCentre forum;

    You could have a timer. Start the timer in the releaseEvent handler and make sure the timeout is long enough to handle the double click first. Then, in the double click event handler you can stop the timer and prevent it from firing. If a double click handler is not triggered, the timer will timeout and call a slot of your choice, where you can handle the single click. This is of course a nasty hack, but has a chance to work.

    wysota

提交回复
热议问题