QMainWindow: how to get a mouseReleaseEvent after resizing?
-
I would like to perform an action after I resize a QMainWindow (dragging the mouseafter cloicking the border or a cornerpoint.)
Straightforward connecting a slot to a resizeEvent is not what I need, as while resizing the QMainWindow many of these events are emitted. I only want to do the action once, only after the 'last resizeEvent'. So I thought to override the 'mouseRelaeseEvent' virtual function in my (subclassed) QMainWindow. However, this does not work. When I release the mouse after dragging the main window at a corner, the mouseReleaseEvent is not entered.Q: how do I catch this mouse release event, after I have changed my QMainWIndow by resizing it at a corner?
Kind Regards,
Bertwim -
@BwvB
According to https://www.qtcentre.org/threads/52916-window-resizing-done?p=237042#post237042, there is no "end resize event", and you have to do byQTimer
after no resize event for a while. Which is what i thought of. Though I would have thought you would need some way of knowing if the user keeps the mouse down yet does not move for a while, so no resize events, but you'll have to investigate.Looks like a more thorough discussion is in https://stackoverflow.com/questions/7753795/qt-user-resize-event-ends-stops
-
@JonB Ah, indeed. Exactly the same question, asked 9 years back! Thanks for pointing me to it, I will investigate the QTimer option. Weird, that this problem needs such an indirect solution, but so be it. I would have expected that releasing the mouse button would have caused some signal to be emitted,
.