【Qt】Qt多屏编程,在指定显示屏上显示指定对话框

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010168781/article/details/81458048

问题描述

主机连接两个显示器,一主一副,要求主显示器显示主界面,副显示器显示一对话窗口

解决方法

使用QDesktopWidget

QDialog dlg = new QDialog(this);
QDesktopWidget* desktop = QApplication::desktop();
this->setGeometry(desktop->screenGeometry(0));   
dlg->setGeometry(desktop->screenGeometry(1));

常用接口

const QRect availableGeometry(int screen = -1) const
const QRect availableGeometry(const QWidget *widget) const
const QRect availableGeometry(const QPoint &p) const
bool isVirtualDesktop() const
int primaryScreen() const
QWidget *screen(int screen = -1)
int screenCount() const
const QRect screenGeometry(int screen = -1) const
const QRect screenGeometry(const QWidget *widget) const
const QRect screenGeometry(const QPoint &p) const
int screenNumber(const QWidget *widget = Q_NULLPTR) const
int screenNumber(const QPoint &point) const

猜你喜欢

转载自blog.csdn.net/u010168781/article/details/81458048