网站首页 > 博客文章 正文
在 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中的类是什么)
你 发表评论:
欢迎- 08-06nginx 反向代理
- 08-06跨表插入连续的日期,sheetsname函数#excel技巧
- 08-06初中生也能学的编程,不走弯路,先用后学
- 08-06find命令的“七种武器”:远不止-name和-type
- 08-06恶意代码常见的编程方式
- 08-06kali2021ping 外网不通
- 08-06因为一个函数strtok踩坑,我被老工程师无情嘲笑了
- 08-06hadoop集群搭建详细方法
- 38℃nginx 反向代理
- 最近发表
- 标签列表
-
- ifneq (61)
- 字符串长度在线 (61)
- googlecloud (64)
- powershellfor (73)
- messagesource (71)
- plsql64位 (73)
- vueproxytable (64)
- npminstallsave (63)
- #NAME? (61)
- promise.race (63)
- 2019cad序列号和密钥激活码 (62)
- window.performance (66)
- qt删除文件夹 (72)
- mysqlcaching_sha2_password (64)
- nacos启动失败 (64)
- ssh-add (70)
- yarnnode (62)
- abstractqueuedsynchronizer (64)
- source~/.bashrc没有那个文件或目录 (65)
- springboot整合activiti工作流 (70)
- jmeter插件下载 (61)
- 抓包分析 (60)
- idea创建mavenweb项目 (65)
- qcombobox样式表 (68)
- pastemac (61)
本文暂时没有评论,来添加一个吧(●'◡'●)