#include "widget.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);//有且只有一个应用程序窗口;
Widget w;//继承自QWidget,QWidget是一个窗口基类,所以Widget也是一个窗口基类;
//窗口默认创建是隐藏的,需要人为显示;
w.show();
//让程序一直执行,等待用户操作,等待事件发生;
return a.exec();
}
Qt project文件
//模块
QT += core gui
//高于4版本,添加QT+=widgets,为了兼容Qt4
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
//应用程序名字
TARGET = Qwidget1
//指定makefile的类型
TEMPLATE = app
DEFINES += QT_DEPRECATED_WARNINGS
CONFIG += c++11
//源文件
SOURCES += \
main.cpp \
widget.cpp
//头文件
HEADERS += \
widget.h
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
Qt widget详解
最新推荐文章于 2024-06-24 20:21:41 发布