In Qt 5, what's the right way to show multi-monitor full screen QWidget windows?

后端 未结 1 1572
温柔的废话
温柔的废话 2020-12-29 05:21

I have a Windows & Mac program that switches into full-screen mode on multiple monitors. In Qt 4, it seems (I can\'t find explicit documentation on how to do this) like

相关标签:
1条回答
  • 2020-12-29 05:24

    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. So you can get that pointer for each window and set a different screen.

    Here is how to show your widget in the last screen in full-screen mode :

    QWidget * widget = new QWidget();
    widget->show();
    widget->windowHandle()->setScreen(qApp->screens().last());
    widget->showFullScreen();
    

    Or in the second screen :

    QWidget * widget = new QWidget();
    widget->show();
    widget->windowHandle()->setScreen(qApp->screens()[1]);
    widget->showFullScreen();
    
    0 讨论(0)
提交回复
热议问题