如何使Widget或Dialog在Qt中不可移动 [英] how to make Widget or Dialog not movable in Qt

查看:264
本文介绍了如何使Widget或Dialog在Qt中不可移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Plz有人帮我找到这个..

解决方案

我认为你可以通过重写 mouseMoveEvent(QMouseEvent * event)。

来自文档:



 mouseMoveEvent()处理鼠标移动事件。默认情况下,仅当用户按住按钮时才会生成这些事件。可以通过调用QWidget :: setMouseTracking()


来改变这种行为。首先,看看这个,它没有回答你的问题,但是提供一些信息。



http: //qt-project.org/doc/qt-4.8/application-windows.html#window-geometry [ ^ ]



虽然我从未这样做过,你可能需要编写自己的类(子类是感兴趣的类),然后覆盖move方法(或者是一个插槽)。是的,它是一个在移动类时调用的方法。我没有检查源,但是,我希望给定移动(x,y)和移动(点),一个调用另一个,但我没有验证这一点。我只是在猜测。



如果你知道这只会用鼠标(而不是键盘)移动,setMouseTracking可能有所帮助,但我没有以任何方式看待它。

Plz some one help me to find this..

解决方案

I think you can subclass QWidget by overriding mouseMoveEvent(QMouseEvent *event).
From documentation:

The mouseMoveEvent() handles "mouse move" events. By default, these events are only generated when the user is holding down a button. It is possible to change this behavior by calling QWidget::setMouseTracking()


First, take a look at this, which does not answer your question, but does provide some information.

http://qt-project.org/doc/qt-4.8/application-windows.html#window-geometry[^]

ALthough I have never done this, you may need to write your own class (sub-class the class of interest) and then over-ride the move method (or is that a slot). Yes, it is a method that is called when the class is moved. I did not check the source, but, I expect that given move(x, y) and move(point), one calls the other, but I did not verify this. I am only guessing.

If you know that this will only be moved using the mouse (and not the keyboard), setMouseTracking may help, but I did not look at that in any way.


这篇关于如何使Widget或Dialog在Qt中不可移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆