当前位置:网站首页>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 {};
边栏推荐
- 这才是开发者神器正确的打开方式
- Error: Protobuf syntax version should be first thing in file
- [semantic segmentation] 2021-pvt iccv
- Use tidymodels to solve the binary logistic model
- 架构实战营模块八作业
- What happens when MySQL tables change from compressed tables to ordinary tables
- Pytorch 入门
- 重磅 | 开放原子校源行活动正式启动
- Understanding of Arduino circuit
- Adcode city code in Gaode map API
猜你喜欢
![[semantic segmentation] 2021-pvt iccv](/img/43/3756c0dbc30fa2871dc8cae5be9bce.png)
[semantic segmentation] 2021-pvt iccv
![[paper reading] i-bert: integer only Bert quantification](/img/2e/4f574b266ec6fc88ffa5dab56f2b8d.png)
[paper reading] i-bert: integer only Bert quantification

这才是开发者神器正确的打开方式

How beautiful can VIM be configured?

阿里P8爆出的这份大厂面试指南,看完工资暴涨30k!

VMWare:使用命令更新或升级 VMWare ESXi 主机

皕杰报表之文本附件属件

重磅 | 2022 开放原子全球开源峰会在北京开幕

Kunlunbase instruction manual (IV) real time synchronization of data from Oracle to kunlunbase

98. (cesium chapter) cesium point heat
随机推荐
Object storage
[configuration related]
LeetCode二叉树系列——144.二叉树的前序遍历
PDF处理还收费?不可能
Oracle advanced (XIV) explanation of escape characters
[QNX hypervisor 2.2 user manual]7.2.1 hypervisor tracking events
Luogu p1816 loyalty solution
阿里P8爆出的这份大厂面试指南,看完工资暴涨30k!
8.穿插-从架构设计到实践理解ThreadPoolExecutor线程池
浅谈安科瑞灭弧式智慧用电在养老机构的应用
静态资源映射
Kunlunbase support for MySQL private DML syntax
Luogu p4185 [usaco18jan]mootube g problem solution
R 语言 用黎曼和求近似 积分
Software testing dry goods
Comprehensive and detailed SQL learning guide (MySQL direction)
Explore SQL Server metadata (I)
SAP Fiori @OData. Analysis of the working principle of publish annotation
使用R包PreMSIm根据基因表达量来预测微卫星不稳定
If distributed file storage is realized according to integrated Minio