Qt 获取屏幕 和窗口大小
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Qt 获取屏幕 和窗口大小相关的知识,希望对你有一定的参考价值。
参考技术A 参考:https://blog.csdn.net/xuebin5260/article/details/50483179https://blog.csdn.net/u013541325/article/details/106966650?utm_medium=distribute.pc_relevant.none-task-blog-baidujs_baidulandingword-0&spm=1001.2101.3001.4242
//获取可用桌面大小
QRect deskRect = QApplication::desktop()->availableGeometry();
int w = deskRect.width();
int h =deskRect.height();
//获取主屏幕分辨率
QRect screenRect = QApplication::desktop()->screenGeometry();
//获取屏幕数量
int nScreenCount = QApplication::desktop()->screenCount();
int width = this->width();//获取窗口宽度
int height = this->height();
int test = 10;
QT 13 窗口屏幕设置大小与居中显示
<pre name="code" class="cpp">#include "mainwindow.h" #include <QApplication> #include <QDesktopWidget> int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); QDesktopWidget *desktop=QApplication::desktop(); w.resize(desktop->width()*3/4,desktop->height()*3/4); w.move((desktop->width()-w.width())/2, (desktop->height()-w.height())/2); return a.exec(); }
以上是关于Qt 获取屏幕 和窗口大小的主要内容,如果未能解决你的问题,请参考以下文章