【发布时间】:2011-10-14 20:37:18
【问题描述】:
我正在开发一个应用程序;它将在具有 2 个显示器的系统上运行。我希望我的 PyQt 应用程序能够自动将特定窗口路由到第二个屏幕。
如何在 Qt 中做到这一点? (在 Python 或 C++ 中)
【问题讨论】:
标签: python qt user-interface pyqt
我正在开发一个应用程序;它将在具有 2 个显示器的系统上运行。我希望我的 PyQt 应用程序能够自动将特定窗口路由到第二个屏幕。
如何在 Qt 中做到这一点? (在 Python 或 C++ 中)
【问题讨论】:
标签: python qt user-interface pyqt
使用QDesktopWidget 访问多头系统的屏幕信息。
这是使小部件覆盖第一个屏幕的伪代码。
QDesktopWidget *pDesktop = QApplication::desktop ();
//Get 1st screen's geometry
QRect RectScreen0 = pDesktop->screenGeometry (0);
//Move the widget to first screen without changing its geometry
my_Widget->move (RectScreen0.left(),RectScreen0.top());
my_pWidget->resize (RectScreen0.width(),RectScreen0.height());
my_Widget->showMaximized();
【讨论】:
以下在 PyQt5 中对我有用
import sys
from PyQt5.QtWidgets import QApplication, QDesktopWidget
app = QApplication(sys.argv)
widget = ... # define your widget
display_monitor = ... # the number of the monitor you want to display your widget
monitor = QDesktopWidget().screenGeometry(display_monitor)
widget.move(monitor.left(), monitor.top())
widget.showFullScreen()
【讨论】: