当前位置: 首页 > news >正文

嵌入式Qt Qt 中的坐标系统

一.Qt中的坐标系统

实验1:窗口坐标大小

#include <QtGui/QApplication>
#include <QPushButton>
#include <QDebug>
#include "widget.h"
int main(int argc, char *argv[])
{QApplication a(argc, argv);Widget w;w.show();qDebug()<<"QWidget:";qDebug()<<w.x();qDebug()<<w.y();qDebug()<<w.width();qDebug()<<w.height();qDebug()<<"QWidget::geometry()";qDebug()<<w.geometry().x();qDebug()<<w.geometry().y();qDebug()<<w.geometry().width();qDebug()<<w.geometry().height();qDebug()<<"QWidget::frameGeometry()";qDebug()<<w.frameGeometry().x();qDebug()<<w.frameGeometry().y();qDebug()<<w.frameGeometry().width();qDebug()<<w.frameGeometry().height();return a.exec();
}QWidget:
192
192
400
300
QWidget::geometry()
201
230
400
300
QWidget::frameGeometry()
192
192
418
347

 

实验2: 每个平台有自己的最小窗口设定,如果代码中设置的窗口大小 小于平台规定大小,那么会默认调整为平台规定的最小大小。 

#include <QtGui/QApplication>
#include <QPushButton>
#include <QDebug>
#include "widget.h"
int main(int argc, char *argv[])
{QApplication a(argc, argv);Widget w;w.resize(100, 100);w.move(120, 120);w.show();qDebug()<<"QWidget:";qDebug()<<w.x();qDebug()<<w.y();qDebug()<<w.width();qDebug()<<w.height();qDebug()<<"QWidget::geometry()";qDebug()<<w.geometry().x();qDebug()<<w.geometry().y();qDebug()<<w.geometry().width();qDebug()<<w.geometry().height();qDebug()<<"QWidget::frameGeometry()";qDebug()<<w.frameGeometry().x();qDebug()<<w.frameGeometry().y();qDebug()<<w.frameGeometry().width();qDebug()<<w.frameGeometry().height();return a.exec();
}QWidget:
120
120
152
100
QWidget::geometry()
129
158
152
100
QWidget::frameGeometry()
120
120
170
147

 二.QPushButton 组件

实验3:QPushButton 使用

#include <QtGui/QApplication>
#include <QPushButton>
#include <QDebug>
#include "widget.h"
int main(int argc, char *argv[])
{QApplication a(argc, argv);Widget w;QPushButton b(&w);// 生成 QPushButton对象, 其父组件为 QWidgetQPushButton b1(&w);b.setText("Button");// 设置显示的字符串b.move(10, 10);     // 移动到坐标 (10, 10)b.resize(100, 50);  // 设置大小 width = 100, height = 25b1.setText("Button"); // 设置显示的字符串b1.move(120, 10);      // 移动到坐标 (120, 10)b1.resize(100, 50);   // 设置大小 width = 100, height = 25w.resize(100, 100);w.move(120, 120);w.show();qDebug()<<"QWidget:";qDebug()<<w.x();qDebug()<<w.y();qDebug()<<w.width();qDebug()<<w.height();qDebug()<<"QWidget::geometry()";qDebug()<<w.geometry().x();qDebug()<<w.geometry().y();qDebug()<<w.geometry().width();qDebug()<<w.geometry().height();qDebug()<<"QWidget::frameGeometry()";qDebug()<<w.frameGeometry().x();qDebug()<<w.frameGeometry().y();qDebug()<<w.frameGeometry().width();qDebug()<<w.frameGeometry().height();return a.exec();
}

 

小结:

Qt中的几何坐标以左上角为原定。

- 水平为X轴,从左向右为正向。

- 垂直为Y轴,从上到下为正向。

Qt 中的GUI组件以左上角进行定位。

Qt 中的GUI组件可以在坐标系统中进行大小设置。

相关文章:

  • 代码随想录算法——数组
  • 【UE 游戏编程基础知识】
  • element-ui解决上传文件时需要携带请求数据的问题
  • 用Python来实现2024年春晚刘谦魔术
  • 操作系统面试问题——说一下什么是零拷贝?
  • 蓝桥杯刷题--python-4
  • 域名解析大概过程笔记
  • Dubbo集成Zookeeper embbed模式
  • 屏幕字体种类介绍
  • 第62讲商品搜索动态实现以及性能优化
  • CVE-2022-0760 漏洞复现
  • 力扣:376. 摆动序列
  • vue监视和深度监视
  • 红队打靶练习:GLASGOW SMILE: 1.1
  • DS Wannabe之5-AM Project: DS 30day int prep day14
  • 「前端」从UglifyJSPlugin强制开启css压缩探究webpack插件运行机制
  • 【每日笔记】【Go学习笔记】2019-01-10 codis proxy处理流程
  • CentOS6 编译安装 redis-3.2.3
  • Docker 笔记(1):介绍、镜像、容器及其基本操作
  • es的写入过程
  • JavaScript 是如何工作的:WebRTC 和对等网络的机制!
  • Spark学习笔记之相关记录
  • SpiderData 2019年2月25日 DApp数据排行榜
  • Spring Boot快速入门(一):Hello Spring Boot
  • Vue.js-Day01
  • Vue官网教程学习过程中值得记录的一些事情
  • 发布国内首个无服务器容器服务,运维效率从未如此高效
  • 工作踩坑系列——https访问遇到“已阻止载入混合活动内容”
  • 机器学习学习笔记一
  • 手机app有了短信验证码还有没必要有图片验证码?
  • 数据科学 第 3 章 11 字符串处理
  • 主流的CSS水平和垂直居中技术大全
  • ​Linux·i2c驱动架构​
  • #《AI中文版》V3 第 1 章 概述
  • #基础#使用Jupyter进行Notebook的转换 .ipynb文件导出为.md文件
  • ()、[]、{}、(())、[[]]等各种括号的使用
  • (C语言)strcpy与strcpy详解,与模拟实现
  • (NO.00004)iOS实现打砖块游戏(十二):伸缩自如,我是如意金箍棒(上)!
  • (三)mysql_MYSQL(三)
  • (转)【Hibernate总结系列】使用举例
  • (转)大道至简,职场上做人做事做管理
  • .NET 8.0 中有哪些新的变化?
  • .Net中wcf服务生成及调用
  • .net专家(张羿专栏)
  • @AutoConfigurationPackage的使用
  • @软考考生,这份软考高分攻略你须知道
  • [ IO.File ] FileSystemWatcher
  • [2024最新教程]地表最强AGI:Claude 3注册账号/登录账号/访问方法,小白教程包教包会
  • [C/C++随笔] char与unsigned char区别
  • [corCTF 2022] CoRJail: From Null Byte Overflow To Docker Escape
  • [HNOI2006]鬼谷子的钱袋
  • [iOS]Win8下iTunes无法连接iPhone版本的解决方法
  • [Kubernetes]2. k8s集群中部署基于nodejs golang的项目以及Pod、Deployment详解
  • [LeetCode]Spiral Matrix
  • [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]对象名 'XXX' 无效