qt5.0
// 获取多显示器,通过list存储当前主机所有显示器
QList<QScreen *> list_screen = QGuiApplication::screens();
// 通过循环可以遍历每个显示器
for (int i = 0; i < list_screen.size(); i++)
{
QRect rect = list_screen.at(i)->geometry();
int desktop_width = rect.width();
int desktop_height = rect.height();
// 打印屏幕分辨率
qDebug() << desktop_width <<desktop_height;
}
//获取主屏分辨率
QRect mRect;
mRect = QGuiApplication::primaryScreen()->geometry();
qDebug()<<"width:"<<mRect.width()<<" height:"<<mRect.height();
this->resize(mRect.width()*543/1920,mRect.height()*494/1080);
show();
qt4.7
QDesktopWidget * dw = QApplication::desktop();
int nCount = dw->screenCount();
QRect dr = dw->availableGeometry(0);