The first program to create a QT

A recent study QT, learning about the recording process, easy review later use. First create a QT program.

The following procedure is based on the window base class Qwidget

 main.c file

#include "widget.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Widget w;
    w.show();

    return a.exec();

Widget inherits from QWidget, and Qwidget is a window class, so Widget is a window class, create another window is hidden by default, we need to artificially display; a.exec () let the program waits for the user to operate.

.pro file

# ------------------------------------------------- 
# 
# Project QtCreator the Created by 2019 - 09 -01T10: 52 : 27 
# 
# --------------------------------- ---------------- 

# module, when used in a class, and sometimes not only need to include the header file 
# items may need to add the appropriate module, this time need go to the appropriate help documentation 
# in to view the 
QT        + = Core the GUI 

# higher than QT4 version, add QT + = Widgets for compatibility Qt4; 
greaterThan (QT_MAJOR_VERSION, 4 ): + = QT Widgets 

name # application (can be changed) 
the TARGET = Qt_01 
TEMPLATE = App 


the SOURCES + = main.cpp \
        widget.cpp

HEADERS  += widget.h

Guess you like

Origin www.cnblogs.com/QingYiShouJiuRen/p/11441764.html