Qt用户调整大小事件结束(停止)
我有一个QWidget,当调整大小事件结束时,我需要执行一些操作(刷新窗口小部件中的图片).我该如何采取行动? 我需要捕捉用户通过释放鼠标键结束所有调整大小操作的时刻.在我的应用程序中,每次调整大小的像素都刷新图像不是一个好习惯.它应该仅在释放鼠标和调整大小操作结束时调用.
I have a QWidget and i need to do some actions (refresh a picture in widget) when resize event ends. How can i catch this action? I need to catch moment when user ENDs all his resize actions by releasing mouse button. It is not a good practice in my application to refresh image every pixel resized. It should calls only when mouse released and resize actions ends.
我只是试图重新实现QMouseReleaseEvent来捕获它,但是当用户按下窗口小部件的边框以调整其大小时,它不起作用.这意味着在我们的情况下不起作用.
I am just tried to reimplement QMouseReleaseEvent to catch it, but it do not works when user presses on the border of widget to resize it. It means does not working in our situation.
然后,我尝试创建自己的QSizeGrip并将其插入我的小部件底部,但是重新实现的事件QMouseReleaseEvent再次在其中不起作用.用户释放鼠标时,事件均不会生成.我不知道为什么.
Then i was tried to create my own QSizeGrip and insert it on the bottom of my widget, but reimplemented event QMouseReleaseEvent again did not work in it. Event did not generates any time user released mouse. I do not know why.
有人可以帮助我解决这个问题吗?
Anybody can help me with that problem?
谢谢.
Windows装饰上的鼠标事件由基础窗口系统管理,这就是为什么您无法在尝试时捕获它们的原因. 我曾经遇到过同样的问题,我选择的解决方案是在每个调整大小事件上(重新)启动单发QTimer,并且仅在经过计时器间隔后才处理更新.不是很性感,但是我没有找到其他解决方法.
Mouse events on windows decoration are managed by the underlying window system, this is why you can't catch them as you tried. I had the same issue once, the solution I chose was to (re)start a singleshot QTimer on each resize event, and only process the update after the timer interval elapsed. Not very sexy but I did not find any other workaround..