当前位置:网站首页>Analysis of QT basic engineering
Analysis of QT basic engineering
2022-07-29 10:46:00 【Cao Lele loves learning】
main.cpp
#include "study1.h"
#include <QApplication>
int main(int argc, char *argv[])//argc Number of command line parameters ;argv Command line arguments
{
QApplication a(argc, argv);// management Qt Program operation , And set up Qt Applications , in the light of QWidewt Applications
// QGuiApplication a(argc, argv);// management Qt Program operation , And set up Qt Applications , For non QWidewt Applications , Such as :QQuick
// QCoreApplication a(argc, argv);// management Qt Program operation , And set up Qt Applications , For applications without interfaces
study1 w;//study1 It's our own class ;w Is the object created
w.show();//w object , Called show() Method , To display the interface
return a.exec();// Return an event cycle ,QEventLoop::exec(), Wait for mouse or keyboard input
}
study1.cpp
#include "study1.h"
#include "ui_study1.h"
#include <QDebug>
study1::study1(QWidget *parent)// Defines an object parent;
: QMainWindow(parent)// And then put parent As Qmainwindow Parameter initialization of ; Initialize object , Written in : after
// Initialize your own variables
,i(4)//i = 4// Because in study.h In file i Variables are written in ui Before the object , So initialize first
, ui(new Ui::study1)//ui = new UI::study1
{
ui->setupUi(this);
qDebug() << " Constructor executed " << endl;
}
study1::~study1()
{
qDebug() << " Destructor executed " << endl;
delete ui;
}
study1.h
#ifndef STUDY1_H
#define STUDY1_H
#include <QMainWindow>
#include <QtNetwork>
QT_BEGIN_NAMESPACE
namespace Ui { class study1; }
QT_END_NAMESPACE
class study1 : public QMainWindow//study1 It's our own class ,QMainWindow The public inherited study1
{
Q_OBJECT// Uppercase is generally macro definition ; Q_OBJECT: Use Qt Signal slot , To call it
public:
study1(QWidget *parent = nullptr);// Constructors ( Press ctrl Click the function name , You can go in )
~study1();// Destructor
// Declare your own variables
int i;
private:
Ui::study1 *ui;// above study1 Not the same , Because different namespaces are used
};
#endif // STUDY1_H
Runtime , perform “ Constructors ”;
When the interface is destroyed , perform “ Destructor ”

study1.ui // Drag and drop empty form
summary :
1、 stay h Declare your own variables in the file
2、 Corresponding cpp Initialize your own variables in the file

3、 And then in qDebug In the line of constructor , Add your own code
Shortcut key :
ctr + a Future generations
ctr + i alignment
ctr + shift + ↑ Move the line up 1 That's ok
ctr + shift + ↓ Move the line down 1 That's ok
F4 Switch between header file and source file
ctr + ← Return to the page before jump
ctr + → Return to the jump just now
A function is declared in the header file : Automatically generate function body

Right click , The function body will be automatically generated

Qt Programming specification
1、 The file name should preferably be lowercase (qtcreater It's not case sensitive by itself )
2、 Reference resources Qt Source code :~/Qt5.12.9/5.12.9/Src
Such as :
3、 It is found that the initials of classes are capitalized , Between words , The initial is in capital
4、 Except for constructors and destructors , The handwritten letters of member functions are all lowercase , Words and their initials are capitalized
5、 Between parameters , It is suggested to add a space
6、 Judgment statement {} Of { And if Itself in the same line ; Only one line , Can not add {};
边栏推荐
- Achieve the effect of a menu tab
- HMS Core Discovery第16期回顾|与虎墩一起,玩转AI新“声”态
- Explore SQL Server metadata (I)
- 为什么要使用markdown进行写作?
- 一文搞懂什么是二叉树(二叉树的种类、遍历方式、定义)
- Object storage
- 架构实战营模块八作业
- Introduction to distributed scheduling xxl-job features
- ggdag 绘制DAG和因果图
- Understand what a binary tree is (types, traversal methods, definitions of binary trees)
猜你喜欢

Conference OA project - my approval

Implementation of college logistics repair application system based on SSM
![[paper reading] i-bert: integer only Bert quantification](/img/2e/4f574b266ec6fc88ffa5dab56f2b8d.png)
[paper reading] i-bert: integer only Bert quantification

Data visualization design guide (information chart)

数据可视化设计指南(信息图表篇)

How to realize the function of adding watermark

If distributed file storage is realized according to integrated Minio

2018-UperNet ECCV

敏捷开发如何消减协作中的认知偏差?| 敏捷之道

Big cloud service company executives changed: technology gives way to sales
随机推荐
HTB-AdmirerToo
[paper reading] q-bert: Hessian based ultra low precision quantification of Bert
Review of the 16th issue of HMS core discovery | play with the new "sound" state of AI with tiger pier
Understand what a binary tree is (types, traversal methods, definitions of binary trees)
[IVI] 17.1 debugging pit FAQ (compilation)
Drunken driving alarm system based on stm32
敏捷开发如何消减协作中的认知偏差?| 敏捷之道
If distributed file storage is realized according to integrated Minio
Pytorch 入门
R 语言 用黎曼和求近似 积分
AI模型风险评估 第2部分:核心内容
Follow teacher Li to learn line generation determinant (continuous update)
What happens when MySQL tables change from compressed tables to ordinary tables
Error: Protobuf syntax version should be first thing in file
How to synchronize when the primary and sub warehouses are modified?
Using Riemann sum to calculate approximate integral in R language
重磅 | 开放原子校源行活动正式启动
How can agile development reduce cognitive bias in collaboration| Agile way
Kunlunbase instruction manual (IV) real time synchronization of data from Oracle to kunlunbase
SAP Fiori @OData. Analysis of the working principle of publish annotation