当前位置:网站首页>Qt学习07 Qt中的坐标系统
Qt学习07 Qt中的坐标系统
2022-06-29 10:30:00 【一个小黑酱】
Qt学习07 Qt中的坐标系统
坐标系统
GUI操作系统都有特定的坐标系统
图形界面程序在坐标系统中进行窗口和部件的定位
定位类型
- 顶级窗口部件的定位
- 窗口内部部件的定位
- 窗口部件的大小设置
Qt使用统一的坐标系统定位窗口部件的位置和大小
Qt部件类提供成员函数在坐标系统中进行定位
QWidget类提供了窗口部件所需的坐标系统成员函数

备注:
屏幕左上角黑色的(0, 0)是窗口在显示屏中位置定位的0坐标;
窗口内部左上角绿色的(0, 0)是客户区位置定位的0坐标。
坐标系统相关的成员函数
- QWidget类中的坐标系统成员函数

备注:
- QWidget的x(),y()是整个窗口在显示屏中的位置,width(),height()是窗口内客户区的宽和高
- geometry()的x(),y(),width(),height()是窗口内部客户区的位置和大小,不包括标题栏和边框,geometry()的width(),height()和QWidget中的width(),height()是一样的
- frameGeometry()的x(),y()和QWidget的x(),y()是一样的,表示窗口在显示屏中的位置,frameGeometry()的width(),height()是整个窗口包含标题栏和边框的宽和高。
Qt为什么要提供3套坐标系统呢?为了解决跨平台,跨操作系统
注意事项
geometry() 和 frameGeometry() 中的几何数据必须在 show() 调用后才有效!!!
窗口部件的大小位置
QWidget类提供了成员函数:
改变窗口部件的大小
void resize(int w, int h)
void resize(const QSize &)
改变窗口部件的位置
void move(int x, int y)
void move(const QPoint &)
QPushButton组件
- QPushButton用于接受用户点击事件
- QPushButton能够显示提示性字符串
- QPushButton是功能性组件,需要父组件作为容器
- QPushButton能够在父组件中进行定位
QWidget w; // 生成QWidget对象,顶级组件
QPushButton b(&w); // 生成QPushButton对象,其父组件为QWidget
b.setText("Button"); // 设置显示的字符串
b.move(10, 10); // 移动到坐标(10, 10)
b.resize(100, 25); // 设置大小width=100, height=25
小结
Qt中的几何坐标以左上角为原点
- 水平为x轴,从左向右为正向
- 垂直为y轴,从上到下为正向
Qt中的GUI组件以左上角进行定位
Qt中的几何坐标以左上角为原点
- 水平为x轴,从左向右为正向
- 垂直为y轴,从上到下为正向
Qt中的GUI组件以左上角进行定位
Qt的GUI组件可以在坐标系统中进行大小设置
边栏推荐
- Modbustcp protocol WiFi wireless learning single channel infrared module (small shell version)
- Limit introduction summary
- 9 款好用到爆的 JSON 处理工具,极大提高效率!
- Interview questions of Tencent automation software test of CSDN salary increase secret script (including answers)
- 期未课程设计:基于SSM的产品销售管理系统
- 【每日3题(3)】重新格式化电话号码
- What are the main factors that affect the heat dissipation of LED packaging?
- By asp Net core downloading files according to the path
- How to obtain method parameter values through WinDbg
- 【每日3题(2)】生成交替二进制字符串的最少操作数
猜你喜欢
![[daily 3 questions (3)] reformat the phone number](/img/ba/0cfe8c084e626615934065b4dee453.png)
[daily 3 questions (3)] reformat the phone number

Live broadcast by technical experts from China Kuwait Fangde: how to build a private cloud platform based on openstack and CEPH| Issue 27

The last 48 hours! The cloud XR theme competition invites you to bloom together. See you at the competition!

【数字信号调制】基于 AM+FM+DSB+SSB实现信号调制解调含Matlab源码

XML外部实体注入漏洞(一)

Design and implementation of IDS

How to obtain method parameter values through WinDbg

math_ Mathematical expression & deformation of equation equation & accumulation of combined operation skills / means

【各种**问题系列】OLTP和OLAP是啥?

直击产业落地!飞桨重磅推出业界首个模型选型工具
随机推荐
what? It's amazing that you can read the whole comic book for free. You can't learn to be a money saver together
Mysql获取表信息
Take another picture of cloud redis' improvement path
How to properly manage temporary files when writing shell scripts
Nature | 全球海洋微生物组的生物合成潜力
那些大佬经常在bash 命令行终端不经意间666飞起的必备操作
[digital signal modulation] realize signal modulation and demodulation based on am+fm+dsb+ssb, including Matlab source code
又拍云 Redis 的改进之路
Shell 引号和转义从来很少被人注意,但平时写脚本又经常用
通过网上进行股票开户安全吗
(JS) observer mode
Live broadcast by technical experts from China Kuwait Fangde: how to build a private cloud platform based on openstack and CEPH| Issue 27
Spark - one to one correspondence between task and partition and detailed explanation of parameters
Bs-gx-017 online examination management system based on SSM
【各种**问题系列】OLTP和OLAP是啥?
在编写shell脚本时如何正确姿势地管理临时文件
中科方德技术专家直播:如何基于 OpenStack、Ceph 构建私有云平台? | 第 27 期
Uboot for embedded driver development -- common command parameters in uboot
Multithreaded high concurrency server: three problems
math_数学表达式&等式方程的变形&组合操作技巧/手段积累