当前位置:网站首页>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
边栏推荐
- MySQL get table information
- Data analysis method and Thinking: funnel analysis
- 【无标题】我在密谋一件大事
- Graduation season · advanced technology Er - workers in the workplace
- arcgis创建postgre企业级数据库
- [3 questions per day (2)] minimum operand for generating alternate binary strings
- Google Earth Engine(GEE)——GEDI L2A Vector Canopy Top Height (Version 2) 全球生态系统数据集
- Uber前安全主管面临欺诈指控 曾隐瞒数据泄露事件
- Easydss is deployed on Disk C, and the video playback cannot be played normally. How to solve this problem?
- How to identify the exact length and width of the contour
猜你喜欢

ModbusTCP协议网络学习型单路红外模块(双层板)

第12周实验---基于FPGA的VGA协议实现

Online text filter less than specified length tool

Graduation season · advanced technology Er - workers in the workplace

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

Data analysis method and Thinking: funnel analysis

Micro blog comment architecture design

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

Google Earth engine (GEE) - Gedi L2a vector canopy top height (version 2) global ecosystem data set

Cornerstone of efficient remote office: effective communication | community essay solicitation
随机推荐
Live broadcast by technical experts from China Kuwait Fangde: how to build a private cloud platform based on openstack and CEPH| Issue 27
ModbusTCP协议WIFI无线学习型单路红外模块(圆壳版)
Shell 引号和转义从来很少被人注意,但平时写脚本又经常用
微博评论架构设计
Today in history: musk was born; Microsoft launches office 365; The inventor of Chua's circuit was born
(JS) array flat
涂鸦云开发 demo 登录
The Chinese Computational Linguistics Conference and the national knowledge atlas and Semantic Computing Conference are in full swing
Necessary for cloud native development: the first common codeless development platform IVX editor
csdn涨薪秘籍之腾讯自动化软件测试面试题(含答案)
【HBZ分享】AQS + CAS +LockSupport 实现ReentrantLock的原理
如何识别出轮廓准确的长和宽
喜报|海泰方圆通过CMMI-3资质认证,研发能力获国际认可
arcgis创建postgre企业级数据库
工具箱之 IKVM.NET 项目新进展
安全 创新 实践|海泰方圆受邀参加“数字时代的网信创新与价值共创”技术交流研讨会
BS-GX-018 基于SSM实现在校学生考试系统
(JS) filter out keys with value greater than 2 in the object
【无标题】我在密谋一件大事
Limit introduction summary