Display window full screen on secondary monitor using Qt

前端 未结 5 439
灰色年华
灰色年华 2020-12-14 03:07

Seems to be possible with native controls (see here and here) so now I\'m looking for some Qt code to do it.

5条回答
  •  渐次进展
    2020-12-14 03:26

    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();
    

提交回复
热议问题