Important: Please read the Qt Code of Conduct -

[Solved] Mouse press and hold event for QWindow?

  • I have a QWindow-derived class and want to know when the user left-mouse clicks and holds down this click. The user will not be moving the mouse at this time. I already catch the MouseButtonPress event when mouse button is pressed down but then no other events are sent until the mouse button is released.

    I saw that the MouseArea QML type has a pressAndHold signal. Is there something like this for QWindow? Or do I need to implement this feature myself.

    I'm using Qt 5.4.

  • may be you can get signals about mouse moving with pressed button throw Drag-and-Drop engine?

  • Lifetime Qt Champion


    AFAIK, there's no equivalent. However you can use e.g. a QTimer for that purpose.

  • I ended up using a QTimer. I basically used \Qt5.4.0\5.4\Src\qtdeclarative\src\plugins\qmltooling\qmldbg_qtquick2\inspecttool.cpp as a guide.

Log in to reply