网站首页 > 博客文章 正文
在 Qt 中,获取全屏的方法有以下几种:
- 使用 QScreen 类:通过 QApplication::screens() 方法获取所有屏幕,然后遍历每个屏幕,再调用其 geometry() 方法获取其矩形区域,即可得到全屏区域。
QList<QScreen*> screens = QApplication::screens();
QRect screenRect;
foreach(QScreen* screen, screens) {
screenRect = screen->geometry();
// ...
}
- 使用 QWidget 类:通过获取主窗口的宽度和高度即可得到全屏区域,这种方法要求主窗口必须是全屏状态,否则无法正确获取全屏区域。
int w = this->width(); // 窗口宽度
int h = this->height(); // 窗口高度
int dw = QApplication::desktop()->width(); // 屏幕宽度
int dh = QApplication::desktop()->height(); // 屏幕高度
QRect fullScreenRect(0, 0, dw, dh); // 全屏矩形区域
- 使用 QDesktopWidget 类:通过获取屏幕的宽度和高度即可得到全屏区域,这种方法不需要主窗口处于全屏状态。
QDesktopWidget* desktopWidget = QApplication::desktop();
int w = desktopWidget->width(); // 屏幕宽度
int h = desktopWidget->height(); // 屏幕高度
QRect fullScreenRect(0, 0, w, h); // 全屏矩形区域
猜你喜欢
- 2025-06-09 详解RTP协议之H264封包和解包实战
- 2025-06-09 Qt开发经验小技巧146-150(qt开发项目)
- 2025-06-09 Qt Concurrent的使用(qt线程使用)
- 2025-06-09 Qt编写全能播放组件(支持ffmpeg2/3/4/5/6/Qt4/5/6)
- 2025-06-09 「Qt入门第24篇」 数据库(四)SQL查询模型QSqlQueryModel
- 2025-06-09 C++解析头文件-Qt自动生成信号声明
- 2025-06-09 这个C++ Qt 文件传输方案性能飙升300%,GitHub冲上热榜
- 2025-06-09 Qt之QTableview显示及单元格内容获取
- 2025-06-09 Qt编程进阶(25):Qt对Excel的基本读写操作
- 2025-06-09 Qt:QFile类(qt中的类是什么)
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- powershellfor (55)
- messagesource (56)
- aspose.pdf破解版 (56)
- promise.race (63)
- 2019cad序列号和密钥激活码 (62)
- window.performance (66)
- qt删除文件夹 (72)
- mysqlcaching_sha2_password (64)
- ubuntu升级gcc (58)
- nacos启动失败 (64)
- ssh-add (70)
- jwt漏洞 (58)
- macos14下载 (58)
- yarnnode (62)
- abstractqueuedsynchronizer (64)
- source~/.bashrc没有那个文件或目录 (65)
- springboot整合activiti工作流 (70)
- jmeter插件下载 (61)
- 抓包分析 (60)
- idea创建mavenweb项目 (65)
- vue回到顶部 (57)
- qcombobox样式表 (68)
- vue数组concat (56)
- tomcatundertow (58)
- pastemac (61)
本文暂时没有评论,来添加一个吧(●'◡'●)