当前位置:网站首页>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组件可以在坐标系统中进行大小设置
边栏推荐
- TTL serial port learning infrared remote control module can be extended to network control
- 毕业季·进击的技术er - 职场打工人
- What are the main factors that affect the heat dissipation of LED packaging?
- Babbitt | yuancosmos daily must read: HTC announced the launch of the first yuancosmos mobile phone, which costs about 2700 yuan. What are the new ways to play
- Online sql to htmltable tool
- What is the experience of working in an IT company in Japan?
- Doodle cloud development demo login
- Hit the industry directly! The first model selection tool in the industry was launched by the flying propeller
- Nature | 全球海洋微生物组的生物合成潜力
- Bs-gx-018 student examination system based on SSM
猜你喜欢

Interview questions of Tencent automation software test of CSDN salary increase secret script (including answers)

【每日3题(3)】重新格式化电话号码

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

Data analysis method and Thinking: funnel analysis

How to obtain method parameter values through WinDbg

math_数学表达式&等式方程的变形&组合操作技巧/手段积累

misc3~7

Modbus RTU protocol 485 learning 2-way infrared module

Today in history: musk was born; Microsoft launches office 365; The inventor of Chua's circuit was born

The first "cyborg" in the world died, and he only transformed himself to "change his life against the sky"
随机推荐
Today in history: musk was born; Microsoft launches office 365; The inventor of Chua's circuit was born
Pipeline aggregations pipeline aggregations - parent-2
Bs-gx-018 student examination system based on SSM
BS-GX-018 基于SSM实现在校学生考试系统
【每日3题(1)】判断国际象棋棋盘中一个格子的颜色
Online sql to htmltable tool
MySQL query table field information
Google Earth Engine(GEE)——GEDI L2A Vector Canopy Top Height (Version 2) 全球生态系统数据集
EasyDSS部署在C盘,录像回看无法正常播放该如何解决?
Map merges the same keys and values into a list
matlab基础 max 求一维或二维数组的最大值+sleep(pause)
LeetCode 535 TinyURL的加密与解密[map] HERODING的LeetCode之路
Spark - Task 与 Partition 一一对应与参数详解
(JS) array de duplication
[digital signal modulation] realize signal modulation and demodulation based on am+fm+dsb+ssb, including Matlab source code
中国计算语言学大会、全国知识图谱与语义计算大会赛题火热进行中
【无标题】我在密谋一件大事
Uber前安全主管面临欺诈指控 曾隐瞒数据泄露事件
[various * * question series] what are OLTP and OLAP?
第12周实验---基于FPGA的VGA协议实现