我在Linux上使用Qt5,我想在第二个屏幕(双监视器)上全屏显示窗口形式吗?我尝试了这段代码,但没有用。还有其他办法吗?

QRect screenres = QApplication::desktop()->screenGeometry(1/*screenNumber*/);
Widget *secondDisplay = new Widget(); // Use your QWidget
secondDisplay->move(QPoint(screenres.x(), screenres.y()));
secondDisplay->resize(screenres.width(), screenres.height());

最佳答案

您可以使用QScreen

QScreen *screen = QGuiApplication::screens()[1]; // specify which screen to use

SecondDisplay secondDisplay = new SecondDisplay(); // your widget

secondDisplay->move(screen->geometry().x(), screen->geometry().y());
secondDisplay->resize(screen->geometry().width(), screen->geometry().height());
secondDisplay->showFullScreen();

09-06 17:43