当前位置:网站首页>QT learning 08 set sail! First application instance
QT learning 08 set sail! First application instance
2022-06-29 11:35:00 【A little black sauce】
Qt Study 08 set sail ! The first application example
Calculator program interface analysis

QLineEdit Components
- QLineEdit be used for Accept user input
- QLineEdit can Get user input string
- QLineEdit yes Functional components , The parent component is required as the container
- QLineEdit can Locate in the parent component
QWidget w; // Generate QWidget object , Top level components
QLineEdit le(&w); // Generate QLineEdit object , Its parent component is QWidget
le.setAlignment(Qt::AlignRight); // Set the display string to the right
le.move(10, 10); // Move to coordinates (10, 10)
le.resize(240, 30); // Set size width=240, height=30
Design and implementation
Interface design
Define the spacing between components
Space = 10px
Define the size of the button component
Width = 40px,Height = 40px
Define the size of the text box component
Width = 5 * 40px + 4 * 10px,Height = 30px

- The problem is
- Calculator program Unwanted Maximize and minimize buttons
- Calculator program window Should be Fixed size
- The text box You cannot enter characters directly
#include <QtGui/QApplication>
#include <QWidget>
#include <QLineEdit>
#include <QPushButton>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget* w = new QWidget(NULL, Qt::WindowCloseButtonHint);
QLineEdit* le = new QLineEdit(w);
QPushButton* button[20] = {
0};
const char* btnText[20] =
{
"7", "8", "9", "+", "(",
"4", "5", "6", "-", ")",
"1", "2", "3", "*", "<-",
"0", ".", "=", "/", "C",
};
int ret = 0;
le->move(10, 10);
le->resize(240, 30);
le->setReadOnly(true);
for(int i=0; i<4; i++)
{
for(int j=0; j<5; j++)
{
button[i*5 + j] = new QPushButton(w);
button[i*5 + j]->resize(40, 40);
button[i*5 + j]->move(10 + (10 + 40)*j, 50 + (10 + 40)*i);
button[i*5 + j]->setText(btnText[i*5 + j]);
}
}
w->show();
w->setFixedSize(w->width(), w->height());
ret = a.exec();
delete w;
return ret;
}
Summary
- GUI Before application development, you should The interface must be designed first
- GUI Application interface Every detail needs to be considered
- The interface determines the end user experience
- Interface details are GUI An important reflection of application quality
- Qt library Ability to achieve Various GUI Application requirements
The interface must be designed first ** - GUI Application interface Every detail needs to be considered
- The interface determines the end user experience
- Interface details are GUI An important reflection of application quality
- Qt library Ability to achieve Various GUI Application requirements
- Qt Help document The use of is... For development It's very important Of
边栏推荐
- The Chinese Computational Linguistics Conference and the national knowledge atlas and Semantic Computing Conference are in full swing
- 中科方德技术专家直播:如何基于 OpenStack、Ceph 构建私有云平台? | 第 27 期
- misc3~7
- Interview questions of Tencent automation software test of CSDN salary increase secret script (including answers)
- Qt学习11 Qt 中的字符串类
- Getting started with the lvgl Library - Animation
- 【HBZ分享】AQS + CAS +LockSupport 实现ReentrantLock的原理
- Live broadcast by technical experts from China Kuwait Fangde: how to build a private cloud platform based on openstack and CEPH| Issue 27
- 直击产业落地!飞桨重磅推出业界首个模型选型工具
- [daily 3 questions (3)] reformat the phone number
猜你喜欢

Modbus RTU protocol 485 learning 2-way infrared module

安全 创新 实践|海泰方圆受邀参加“数字时代的网信创新与价值共创”技术交流研讨会

Bs-gx-018 student examination system based on SSM

斐波那锲数列与冒泡排序法在C语言中的用法

(JS) array de duplication

Graduation season · advanced technology Er - workers in the workplace

When the "Ai x scientific computing" is in progress, Huawei's mindspore competition question is hot, waiting for you!

Evaluation of IP location query interface Ⅱ

Spark - one to one correspondence between task and partition and detailed explanation of parameters

BS-GX-018 基于SSM实现在校学生考试系统
随机推荐
【各种**问题系列】OLTP和OLAP是啥?
ModbusTCP协议网络学习型单路红外模块(中壳版)
What are the pop, push, unshift, and shift of the (JS) array?
Adding sharding sphere5.0.0 sub tables to the ruoyi framework (adding custom sub table policies through SPI)
Pipeline aggregations pipeline aggregation-sibling-1
5. migrate uboot set default environment variables, crop, and partition
【无标题】我在密谋一件大事
Shell 引号和转义从来很少被人注意,但平时写脚本又经常用
影响LED封装散热主要因素有哪些?
云原生开发必备:首个通用无代码开发平台 iVX 编辑器
Spark - Task 与 Partition 一一对应与参数详解
BS-GX-017基于SSM实现的在线考试管理系统
Qt学习15 用户界面与业务逻辑的分离
How to properly manage temporary files when writing shell scripts
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
Qt学习11 Qt 中的字符串类
(JS) array methods: slice and slice
After 22 years in office, the father of PowerShell will leave Microsoft: he was demoted by Microsoft for developing PowerShell
高效远程办公的基石:有效沟通 |社区征文
Today in history: musk was born; Microsoft launches office 365; The inventor of Chua's circuit was born