In my Qt application, I have couple of QtWidgets which are floating. I want to know when QtWidget is dragged to another screen So that I can resize content within according to new screen DPI.
Asked
Active
Viewed 1,512 times
4
-
What about querying `QDesktopWidget::screenNumber()` periodically? – vahancho Nov 20 '20 at 13:55
-
did you ever find a solution to this? – codeling Jul 11 '22 at 12:20
-
Listened to event void QWindow::screenChanged(QScreen *screen) – living on edge Aug 20 '23 at 14:04
1 Answers
0
Connect the primaryScreenChanged
signal from your QGuiApplication
to slots in your widgets.
Edited to add: On reflection, this probably doesn't do what you want -- it signals when the application changes screen, not the widget.

TonyK
- 16,761
- 4
- 37
- 72
-
One Query, My application has lot of QDialogs, so this signal is emitted. only one Qdialog is moved other screen not main application window. – living on edge Nov 23 '20 at 03:12
-
I have DISPLAY1 and DISPLAY2, DISPLAY1 is primary, when DISPLAY1 HDMI is plug out, after primaryScreenChanged signal, MainWindow is shown on secondary screen DISPLAY2, but MainWindow->screen() is still DISPLAY1. – Acewind Apr 06 '23 at 07:27