Seems to be possible with native controls (see here and here) so now I'm looking for some Qt code to do it.
Asked
Active
Viewed 3.1k times
5 Answers
20
One way of doing it in Qt5 is to use QWindow::setScreen
to set the screen on which the window should be shown. QWidget
has a windowHandle()
that returns the pointer to the QWindow
.
Here is how to show your widget on second screen in full-screen mode :
QWidget * widget = new QWidget();
widget->show();
widget->windowHandle()->setScreen(qApp->screens()[1]);
widget->showFullScreen();

Nejat
- 31,784
- 12
- 106
- 138
19
I use this code for the second display in full screen successfully on both Windows & Linux
QRect screenres = QApplication::desktop()->screenGeometry(1/*screenNumber*/);
SecondDisplay secondDisplay = new SecondDisplay(); // Use your QWidget
secondDisplay->move(QPoint(screenres.x(), screenres.y()));
secondDisplay->resize(screenres.width(), screenres.height());
secondDisplay->showFullScreen();

mmonem
- 2,811
- 2
- 28
- 38
-
1This doesn't work longer in Qt5. QWidget is shown on the first screen. – fdermishin Mar 11 '13 at 21:37
-
2Confirmed not working on Qt5. Moving window after setting fullscreen appears to work. – eozgonul Jan 10 '14 at 09:04
-
I think problem with this code is that screen sizes may vary so just dividing full resolution with screencount is a gamble that may work depending on your screen resolutions. – Mr. Developerdude Feb 23 '15 at 22:29
6
My take on this:
auto const desktop(QApplication::desktop());
setGeometry(desktop->screenGeometry(1));
#ifndef Q_OS_WIN
setWindowState(Qt::WindowState(Qt::WindowFullScreen | windowState()));
#endif // Q_OS_WIN

user1095108
- 14,119
- 9
- 58
- 116
5
showFullScreen first, then setGeometry.
Qt5 tested OK

user2253705
- 51
- 1
- 3
-
Would you mind including a code sample? It would make your answer more valuable. – Simon MᶜKenzie May 24 '13 at 02:18
-
This actually does not work, WindowState is reverted to NoState when you call setGeometry. – eozgonul Jan 10 '14 at 11:37
-1
This problem got solved while using window->showFullScreen() instead of window->show().

Debangana
- 87
- 3