qt窗口坐标

新建一个mainwindow的工程,运行。

 

 窗口的坐标:

代码:

复制代码
 1 //窗口左上角的位置(含边框)
 2     qDebug() << "1(含边框):" << this->frameGeometry().x() << this->frameGeometry().y();//1
 3     qDebug() << "2(含边框):" << this->x()  << this->y();//2
 4     qDebug() << "3(含边框):" << this->pos().x() << this->pos().y();//3
 5     //窗口的宽度和高度(含边框)
 6     qDebug() << "4(不含边框):" << this->frameGeometry().width() << this->frameGeometry().height();
 7     //窗口左上角的位置(不含边框)
 8     qDebug() << "5(不含边框):" << this->geometry().x() << this->geometry().y();
 9     //窗口的宽度和高度(不含边框)
10     qDebug() << "6(不含边框):" << this->geometry().width() << this->geometry().height();//1
11     qDebug() << "7(不含边框):" << this->width() << this->height();//2
12     qDebug() << "8(不含边框):" << this->rect().width() << this->rect().height();//3
13     qDebug() << "9(不含边框):" << this->size().width() << this->size().height();//4
复制代码

输出:

复制代码
1(含边框): 989 578
2(含边框): 989 578
3(含边框): 989 578
4(不含边框): 902 519
5(不含边框): 1002 636
6(不含边框): 876 448
7(不含边框): 876 448
8(不含边框): 876 448
9(不含边框): 876 448
复制代码

 

posted @   阳光下的小土豆  阅读(80)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
历史上的今天:
2021-10-13 linux(中标麒麟) 获取硬盘信息
点击右上角即可分享
微信分享提示