Qt:mouseMoveEvent并干扰子对象的hoverEnterEvent
我使用 QGraphicsView 创建一种电路编辑器,其中包含带有连接器的元素。 应该可以用电线连接这些连接器。 但是,我遇到了一个问题,当我从一个连接器拖动到另一个连接器时,Qt 抓住鼠标,而其他连接器停止接收 hoverEnterEvent
。 顺便说一句,悬停连接器会调整大小,因此更容易击中它们。
再次,拖动时是否可以不抓取鼠标?
我使用的是 Windows 版 Qt 4.5。
根据要求,以下是一些来源: http://pastebin.com/m422b9495
I use QGraphicsView
to create a sort of circut editor, which has elements in it, which have connectors. It should be possible to connect those connectors with wires.
However, I have a problem, while I drag from one connector to another, Qt grabs mouse, and other connectors stop receiving hoverEnterEvent
. Btw, on hover connectors resize, so it's easier to hit them.
Once again, is it possible not to grab mouse while drag?
I have used Qt 4.5 for Windows.
As requested, here are some sources:
http://pastebin.com/m422b9495
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以在源项目中使用 mouseMoveEvent 来检查光标何时位于目标项目上。
例如:
You could use the mouseMoveEvent in the source item to check when the cursor is over the target item.
For example:
在拖动操作期间更改鼠标悬停行为是比较典型的。 通常响应鼠标移动的小部件在拖动过程中往往不会响应,除非它们可以接收关联的放置。 因此通常的悬停事件被抑制。 (检查小部件是否接受某些放置是不够的,因为问题是小部件是否可以接受此放置。)除了悬停事件之外,请尝试使用拖动的输入和离开事件来调整连接器的大小。
It is somewhat typical to change the mouse-over behavior during a drag operation. Widgets that normally respond to mouse movement tend to not respond during a drag unless they can receive the associated drop. So the usual hover events are suppressed. (Checking whether or not a widget accepts some drops is inadequate since the question is whether or not the widget might accept this drop.) Try using the drag's enter and leave events to resize your connectors, in addition to the hover events.
我认为您需要将 交互模式 设置为 false。
另请参阅 DragMode
I think you need to set interactive mode to false.
See also DragMode