当前位置:网站首页>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 {};
边栏推荐
- Atomic operation of day4 practice in 2022cuda summer training camp
- R language Monte Carlo method and average method are used to calculate the definite integral. Considering the random point casting method, the confidence is 0.05, and the requirement is ϵ= 0.01, numbe
- 12代酷睿处理器+2.8K OLED华硕好屏,灵耀14 2022影青釉商务轻薄本
- Scrape crawler framework
- Second handshake?? Three waves??
- Easy to understand and explain the gradient descent method!
- Follow teacher Wu to learn advanced numbers - function, limit and continuity (continuous update)
- Data office system
- ECCV 2022 | CMU proposes to recurse on the visual transformer without adding parameters, and the amount of calculation is still small
- [configuration related]
猜你喜欢

Open source, compliance escort! 2022 open atom global open source summit open source compliance sub forum is about to open

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

Drunken driving alarm system based on stm32

Easy to understand and explain the gradient descent method!

周鸿祎:360是世界上最大的安全大数据公司

12th generation core processor +2.8k OLED ASUS good screen, lingyao 142022 shadow cyan glaze business thin book

二次握手??三次挥手??

8.穿插-从架构设计到实践理解ThreadPoolExecutor线程池

Oracle advanced (XIV) explanation of escape characters
![[paper reading] i-bert: integer only Bert quantification](/img/2e/4f574b266ec6fc88ffa5dab56f2b8d.png)
[paper reading] i-bert: integer only Bert quantification
随机推荐
这才是开发者神器正确的打开方式
Atomic operation of day4 practice in 2022cuda summer training camp
Easy to understand and explain the gradient descent method!
Static resource mapping
为什么要使用markdown进行写作?
Kunlunbase instruction manual (I) quick installation manual
Oncopy and onpaste
Luogu p4185 [usaco18jan]mootube g problem solution
使用 RTCGA 临床数据进行生存分析
软件测试干货
[QNX hypervisor 2.2 user manual]7.2.1 hypervisor tracking events
VMWare:使用命令更新或升级 VMWare ESXi 主机
Is error log monitoring enough? Don't try JVM monitoring of microservices
12th generation core processor +2.8k OLED ASUS good screen, lingyao 142022 shadow cyan glaze business thin book
R language Monte Carlo method and average method are used to calculate the definite integral. Considering the random point casting method, the confidence is 0.05, and the requirement is ϵ= 0.01, numbe
HMS Core Discovery第16期回顾|与虎墩一起,玩转AI新“声”态
Use R-Pack skimr to collect the beautiful display of President measurement
Understand what a binary tree is (types, traversal methods, definitions of binary trees)
This is the right way for developers to open artifacts
敏捷开发如何消减协作中的认知偏差?| 敏捷之道