当前位置:网站首页>Basic knowledge of QT original code
Basic knowledge of QT original code
2022-07-02 14:09:00 【Shimmering bagpipe】
untitled1.pro
#-------------------------------------------------
#
# Project created by QtCreator 2022-06-28T09:57:30
#
#-------------------------------------------------
# Qt Modules applied to
QT += core gui
# Compatible with previous Qt edition ( It doesn't usually change )
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
# The name of the generated application
TARGET = untitled1
# Refers to generated makfile type
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
# Source file
SOURCES += \
main.cpp \
widget.cpp
# The header file
HEADERS += \
widget.h
# UI file
FORMS += \
widget.ui
# Qt Modules applied toQT += core gui# Compatible with previous Qt edition ( It doesn't usually change )greaterThan(QT_MAJOR_VERSION, 4): QT += widgets# The name of the generated applicationTARGET = untitled1# Refers to generated makfile typeTEMPLATE = app
widget.h in
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
// Definition UI The namespace of
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT // macro If signals and slots are used , This class must be added
public:
explicit Widget(QWidget *parent = 0);
~Widget();
private:
Ui::Widget *ui; // use UI In the namespace Widget class , Define a pointer *ui
};
#endif // WIDGET_H
Q_OBJECT // macro If signals and slots are used , This class must be added
Ui::Widget *ui; // use UI In the namespace Widget class , Define a pointer *ui
widget.cpp in
#include "widget.h"
#include "ui_widget.h"
// Constructors
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
}
Widget::~Widget()
{
delete ui;
}
main.cpp
#include "widget.h" // Because the main function uses a window , Need to import header file
#include <QApplication>
int main(int argc, char *argv[])
{
// Application class , Every Qt There is only one application object in the application
QApplication a(argc, argv);
// Window classes create window objects , When the window is created, it will not be displayed by default
Widget w; // top window
w.show(); // Window display
return a.exec(); // The application object runs
}
exec() What is the function of ?
The function is to start a cycle , Execute an event , amount to while(1) and for(;;). Make sure the window doesn't flash
边栏推荐
猜你喜欢
Design of non main lamp: how to make intelligent lighting more "intelligent"?
Téléchargement par navigateur
c# 水晶报表打印
Getting started with QT - making a simple calculator
每日学习2
Use of UIC in QT
MySQL45讲——学习极客时间MySQL实战45讲笔记—— 04 | 深入浅出索引(上)
Memory management 01 - link script
Do you know that there is an upper limit on the size of Oracle data files?
联合搜索:搜索中的所有需求
随机推荐
【文档树、设置】字体变小
Data consistency between redis and database
[USACO05JAN]Watchcow S(欧拉回路)
Winter vacation daily question - lucky numbers in the matrix
selenium的特点
Qt如何设置固定大小
selenium 元素定位方法
Design of non main lamp: how to make intelligent lighting more "intelligent"?
c# 水晶报表打印
kaggle如何使用utility script
Integral link, inertia link and proportion link in Simulink
Development skills of rxjs observable custom operator
[to be continued] [UE4 notes] l5ue4 model import
[template] longest common subsequence ([DP or greedy] board)
石子合并板子【区间DP】(普通石子合并 & 环形石子合并)
(POJ - 1984) navigation nightare (weighted and search set)
Systemserver process
P1347 sorting (topology + SPFA judgment ring or topology [inner judgment ring])
自定义事件,全局事件总线,消息订阅与发布,$nextTick
代码实现MNLM