当前位置:网站首页>QT tutorial: creating the first QT program
QT tutorial: creating the first QT program
2022-07-07 00:26:00 【Cheems_ Pak Choi】
One 、 Leading knowledge
1、 The base class represents the parent class 、 Derived classes represent subclasses
2、 Base class QWidget yes QDialog and QMainWindow Parent class of
3、 If you create one, you need to have a menu bar 、 The toolbar 、 Status bar, etc. , You can choose QMainWindow As the base class
4、QDialog As a base class , It's just a simple dialog , There is only one close button in the upper right corner x
Two 、 After the project is successfully created, the code is as follows
1、main.cpp in
#include “mywidget . h” // The class name is the same as the header file name
#include
// Application entry
int main(int argc , char * argv [ ])
{
QApplication a (argv , argv);//QApplication Represents the application class , In every one of them qt There is and only one in the program
MyWidget w;//MyWidget Represents a window class ( After the window class is created, it is not displayed by default , So we'll show it later ),w Represents the object that created a window class
w . show();// Show window ,w It refers to the whole window , When we do other operations on this window , It is equivalent to operating it
return a . exec(); // Cycle through the window , When a trigger signal or event is received , It will jump out , For example, when closing a window , It will jump out of this cycle
}
2、mywidget.h in
#ifndef MYWIDGET_H
#define MYWIDGET_H
#include
class MyWidget( Subclass ) : public QWidget ( Parent class )
{
Q_OBJECT // If signal and slot mechanisms are used , You must add this macro
public :
MyWidget (QWidget *parent = 0) ;// Constructors
~MyWidget(); // Destructor
};
#endif
3、mywidget.cpp in
#include “mywidget.h”
MyWidget::MyWidget(QWidget *parent)
: QWidget(parent)
{
}
MyWidget::~MyWidget()
{
}
4、xxxxx.pro In Engineering
QT += core gui //qt Modules used in the program
greaterThan(QT_MAJOR_VERSON,4): QT += widgets // For compatibility with previous versions
TARGET = xxxxx // Generated application name
TEMPLATE = app // Specify the generated makefile The type of lib
SOURCE +=main.cpp
mywidget.cpp // Source file
HEADERS +=mywidget.h // The header file
5、 If a new window needs to be attached to another window , You need to specify a parent class for this window ( It means that the new window is not independent , Instead, it is built in the parent window )
6、QT After creating pointer in , The condition that memory can be recycled automatically
1) from QObject Derived classes :1. direct 2. indirect
2) Specify the parent class , When father deconstructs , First analyze its child paper
边栏推荐
- [CVPR 2022] semi supervised object detection: dense learning based semi supervised object detection
- C语言输入/输出流和文件操作【二】
- PostgreSQL高可用之repmgr(1主2从+1witness)+Pgpool-II实现主从切换+读写分离
- Racher integrates LDAP to realize unified account login
- How about the order management of okcc call center
- 2022年PMP项目管理考试敏捷知识点(9)
- 17、 MySQL - high availability + read / write separation + gtid + semi synchronous master-slave replication cluster
- web渗透测试是什么_渗透实战
- iMeta | 华南农大陈程杰/夏瑞等发布TBtools构造Circos图的简单方法
- Encryption algorithm - password security
猜你喜欢
How rider uses nuget package offline
沉浸式投影在线下展示中的三大应用特点
37页数字乡村振兴智慧农业整体规划建设方案
Designed for decision tree, the National University of Singapore and Tsinghua University jointly proposed a fast and safe federal learning system
What is a responsive object? How to create a responsive object?
What can the interactive slide screen demonstration bring to the enterprise exhibition hall
uniapp中redirectTo和navigateTo的区别
Uniapp uploads and displays avatars locally, and converts avatars into Base64 format and stores them in MySQL database
DAY TWO
The way of intelligent operation and maintenance application, bid farewell to the crisis of enterprise digital transformation
随机推荐
openresty ngx_lua子请求
Leecode brush question record sword finger offer 58 - ii Rotate string left
DAY SIX
DAY ONE
DAY FIVE
On February 19, 2021ccf award ceremony will be held, "why in Hengdian?"
MySQL master-slave multi-source replication (3 master and 1 slave) setup and synchronization test
Racher integrates LDAP to realize unified account login
"Latex" Introduction to latex mathematical formula "suggestions collection"
[CVPR 2022] target detection sota:dino: Detr with improved detecting anchor boxes for end to end object detection
How about the order management of okcc call center
Sword finger offer 26 Substructure of tree
The programmer resigned and was sentenced to 10 months for deleting the code. Jingdong came home and said that it took 30000 to restore the database. Netizen: This is really a revenge
[boutique] Pinia Persistence Based on the plug-in Pinia plugin persist
DAY THREE
Personal digestion of DDD
2021 SASE integration strategic roadmap (I)
DAY THREE
How to use vector_ How to use vector pointer
pytest多进程/多线程执行测试用例