QT入门(一)

安装 http://www.qt.io/download/

然后设置编译器 调试器 QT库版本

QT-tool:

  1. QT Assistant
  2. QT Designer
  3. QT Examples and Demos
  4. QT Linguist


QT入门(一)

QT入门(一)

QT入门(一)

QT入门(一)

QT入门(一)

QT入门(一)


QT入门(一)


//hello.cpp
#include "hello.h"
#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QLabel* label = new QLabel("<h2>hello</h2>");//simple html layout
    label->show();
    return a.exec();
}

//buildconn
#include "buildconn.h"
#include <QApplication>
#include <QPushButton>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QPushButton* button = new QPushButton("quit");
    QObject::connect(button, SIGNAL(clicked(bool)), &a, SLOT(quit()));
    button->show();
    return a.exec();
}

ctrl+space 强制补全

qmake -project (convert .pro to Makefile)

qmake

make (complier)

uic -o ui.h ui.ui //编译UI

QT入门(一)

QT入门(一)

ctrl + num 快捷键

#-------------------------------------------------
#
# Project created by QtCreator 2018-06-13T03:19:52
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = TopC
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


SOURCES += \
        main.cpp \
        topc.cpp

HEADERS += \
        topc.h

FORMS += \
        topc.ui

QT入门(一)