QApplication primary screen changed
-
@ChrisW67 so, I have QApplication. And I have popup notification widget showing in the bottom right corner of screen. I need show popup widget on the same screen where showing currently main application window.
Thank you. -
@Alexey-Serebryakov
You should be able to find your main widget using QApplication::topLevelWidgets()
Then you can get the screen using QWidget::screen()Or so I would imagine.
-
@Asperamanca Ok/ And then? Before I used QDesktopWidget class but now that is obsolete and recomended use QScreen and so on. But QScreen not derived from QWidget. How can I show widget on screen specified? For example I have popup notification widget in my application and I want show that on screen specified. That mean the QDesktopWidget object was parent for my popup widget. But now my popup widget shows only on primary display. :-(
-
@Alexey-Serebryakov said in QApplication current screen:
does not work
Such statements are really not helpful.
In what way it "does not work"?
Does the connection fail (please use new connect sintax instead of the old one you're using now)!
Does the connection succeed but the slot is not called? -
@jsulm yeah connection succeed but the slot is not called.
connect(qGuiApp, &QGuiApplication::primaryScreenChanged, this, &DefaultNotification::OnScreenChanged); ... void DefaultNotification::OnScreenChanged(QScreen *screen) { currentScreen_ = screen; qInfo() << "Screen was changed to " << screen->name(); }
Hmm... when this slot must me called? When I move main window to another screen?
-
@Alexey-Serebryakov said in QApplication current screen:
How can I show widget on screen specified?
-
-
@Alexey-Serebryakov said in QApplication primary screen changed:
QGuiApplication::primaryScreenChanged
In Windows the primary screen is the one showing the full task bar. The changed signal will only be emitted when you change the primary screen in your Windows settings. It is not related to moving the widget from one screen to the other.