[英]Qt: How to be notified when a row is hovered in a QFormLayout?
I have a QFormLayout where the left widgets are QLabels and the right widgets are of various types. 我有一个QFormLayout,左边的小部件是QLabel,右边的小部件是各种类型的。 I want to get notified when the mouse enters any part of a form-row, so I can display an explanation of that row in my statusbar.
我想在鼠标进入表格行的任何部分时收到通知,因此我可以在状态栏中显示该行的说明。
Currently I have a QLabel subclass called HoverableLabel which exposes "mouseEntered" and "mouseLeft" signals (emitted in my reimplementations of enterEvent and leaveEvent). 目前我有一个名为HoverableLabel的QLabel子类,它暴露了“mouseEntered”和“mouseLeft”信号(在我重新实现的enterEvent和leaveEvent中发出)。 This works, but:
这有效,但是:
What's the Qt-blessed approach to this kind of problem? 什么是Qt祝福这种问题的方法?
Some things I can think of: 我能想到的一些事情:
Neither is very nice. 两者都不是很好。
I ended up using the first of the two solutions. 我最终使用了两个解决方案中的第一个。 Good enough, and with some work it can be isolated into a reusable subclass of QFormLayout.
足够好,通过一些工作,它可以被隔离成QFormLayout的可重用子类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.