Qt: How to get notified when a string freezes in a QFormLayout?

I have a QFormLayout where the left widgets are QLabels and the correct widgets are of different types. I want to be notified when the mouse enters any part of the form line, so I can display an explanation of this line in my status bar.

I currently have a QLabel subclass called HoverableLabel that provides mouseEntered and mouseLeft signals (emitted in my reimplementations of enterEvent and leaveEvent). This works, but:

  • Fields between lines do not cause signals
  • The space to the left of (aligned to the right) labels does not cause a signal
  • The widgets on the right do not trigger a signal because I did not bother to subclass them all

What is a Qt-blessed approach to this problem?

Some things I can think of:

  • Create a formlayout parent widget that filters all the mousemove events (mouse tracking?) And checks to see if the mouse has been specified on some line.
  • Change the formlayout in QVBoxLayout and make the lines into some custom widget, such as FormRowWidget, which handles both hover events and form alignment elements.

Nothing good.

+4
source share
1 answer

In the end, I used the first of two solutions. Good enough, and with some work, it can be allocated to a reusable subclass of QFormLayout.

0
source

All Articles