Is there a knows bug with QApplication::desktop()->screenNumber(this) reporting the wrong screen?
-
wrote on 27 Jul 2015, 09:26 last edited by koahnig
I've got a bit of an odd setup with 3 different sized monitors in my work configuration. But I've noticed what appears to be a bug in the Qt desktop screen code.
When my mainwindow is initially shown on one of the secondary screens.
qApp->desktop()->screenNumber(this)
will still return 0 for the main screen even though the window is on one of the other two screens. Of cause giving the screenNumber call a QPoint will give the correct screen number.auto globalCenter = this->mapToGlobal(this->geometry().center()); screenIdx = qApp->desktop()->screenNumber(globalCenter);
So this is a possible workaround. But calling showFullScreen will incorrectly show the mainwindow in full screen mode on screen 0 effectively moving the window to another monitor in this case. I've had to resort to this kind of hackery to get around this issue:
void MainWindow::toggleFullscreen() { // ensure winow is on the correct screen before going full screen auto screenIdx = mApp().desktop()->screenNumber(this); if (screenIdx >= 0 && screenIdx < QGuiApplication::screens().count()) { auto* screen = QGuiApplication::screens()[screenIdx]; if (screen && windowHandle()->screen() != screen) windowHandle()->setScreen(screen); } ...
Is this a previously known error or am I missing something here?
-
wrote on 27 Jul 2015, 10:38 last edited by
Are you aware of Qt's bug tracking system JIRA?
There you can check also for bugs. -
Are you aware of Qt's bug tracking system JIRA?
There you can check also for bugs.wrote on 27 Jul 2015, 13:14 last edited by@koahnig I did search the Qt bug tracking system before. But it's huge and I'm probably not creative enough to come up with fitting search terms as I can't find anything on this. Just hoping someone else have run into this before and can confirm it's a Qt bug and not me.
-
wrote on 27 Jul 2015, 14:14 last edited by
I know this problem. ;)
I have never found an index in a book stating "the solution to your problem is on page xx".
Add a tag to multi-screen. There is also another post to a bug, but probably unrelated.
1/4