当前位置:网站首页>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
边栏推荐
- Getting started with QT - making a simple calculator
- kaggle如何使用utility script
- How to use SAP's metadata framework (MDF) to build custom business rules?
- c# 水晶报表打印
- 每天坚持20分钟go的基础二
- Analysis of CPU surge in production environment service
- QT how to set fixed size
- 693. Travel sequencing (map + topology)
- Dingtalk 发送消息
- How to set QT manual layout
猜你喜欢

Sum of the first n terms of Fibonacci (fast power of matrix)

Qt入门-制作一个简易的计算器

C crystal report printing

(POJ - 1984) navigation nightare (weighted and search set)

selenium,元素操作以及浏览器操作方法
![Unity small map production [2]](/img/d6/9d6556d37525b9986b74133f2a7aaa.jpg)
Unity small map production [2]

大家信夫一站式信用平台让信用场景“用起来
[document tree, setting] font becomes smaller

Do you know that there is an upper limit on the size of Oracle data files?

无主灯设计:如何让智能照明更加「智能」?
随机推荐
Data Lake (11): Iceberg table data organization and query
QT how to set fixed size
Qt新建项目
MySQL45讲——学习极客时间MySQL实战45讲笔记—— 04 | 深入浅出索引(上)
Will your sleep service dream of the extra bookinfo on the service network
Story points vs. human days
Runhe hi3516 development board openharmony small system and standard system burning
Whole house Wi Fi: a pain point that no one can solve?
2022家用投影仪首选!当贝F5强悍音画效果带来极致视听体验
The xftp connection Haikang camera reported an error: the SFTP subsystem application has been rejected. Please ensure that the SFTP subsystem settings of the SSH connection are valid
P3008 [USACO11JAN]Roads and Planes G (SPFA + SLF优化)
[usaco05jan]watchcow s (Euler loop)
每日学习2
故事点 vs. 人天
QT - make a simple calculator - realize four operations
Android kotlin material design technology points
P1908 reverse sequence pair
rxjs Observable 自定义 Operator 的开发技巧
693. Travel sequencing (map + topology)
Federated Search: all requirements in search