Search code examples
qwidget

How to avoid QWidget from going out of sight


Is there a way to avoid a QWidget from going out of sight?

I've got a line connecting some points; every point shows a widget (always the same) with some values; if I move the mouse over a point close to the right margin of the monitor, the QWidget will be shown just partially (a part will be out of the monitor).

How can I force the widget to be fully shown when needed, maybe on the left of the mouse?

Thanks to all.


Solution

  • you can compare the QWidgets boundingRect() and the QDesktopWidgets boundingRect() if outside, move the widget back ;)