1_简介.md

简介

image-20200201215614193

第一个程序

窗口类:QWidget, QMainWindow, QDialog

main:

#include "mywidget.h"
#include <QApplication> //包含一个应用程序类的头文件
int main(int argc, char *argv[])
{
// 应用程序对象,在qt中,有且仅有一个
QApplication a(argc, argv);
// 窗口对象, MyWidget -> QWidget
MyWidget w;
// 显示窗口
w.show();
// 让应用程序对象进入消息循环
return a.exec();
}

mywidget.h:

#ifndef MYWIDGET_H
#define MYWIDGET_H
#include <QWidget> //QWidget 窗口类
class MyWidget : public QWidget
{
Q_OBJECT // 宏, 允许类使用信号和槽的机制
public:
MyWidget(QWidget *parent = nullptr); // 构造函数
~MyWidget(); // 析构函数
};
#endif // MYWIDGET_H

qtcreator 配置文件

QT += core gui #qt 包含的模块
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets # >=4版本
CONFIG += c++11
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked 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 it uses 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 \
mywidget.cpp
HEADERS += \
mywidget.h
TRANSLATIONS += \
test_zh_CN.ts
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

Qt基本模块

Qt 基本模块是 Qt 在所有平台上的基本功能,它们在所有的幵发平台和目标平台上都可用,在 Qt 5 所有版本上是源代码和二进制兼容的。这些具体的基本模块见表 1。

模块 描述
Qt Core 其他模块都用到的核心非图形类
Qt GUI 设计 GUI 界面的基础类,包括 OpenGL
Qt Multimedia 音频、视频、摄像头和广播功能的类
Qt Multimedia Widgets 实现多媒体功能的界面组件类
Qt Network 使网络编程更简单和轻便的类
Qt QML 用于 QML 和 JavaScript 语言的类
Qt Quick 用于构建具有定制用户界面的动态应用程序的声明框架
Qt Quick Controls 创建桌面样式用户界面,基于 Qt Quick 的用户界面控件
Qt Quick Dialogs 用于 Qt Quick 的系统对话框类型
Qt Quick Layouts 用于 Qt Quick 2 界面元素的布局项
Qt SQL 使用 SQL 用于数据库操作的类
Qt Test 用于应用程序和库进行单元测试的类
Qt Widgets 用于构建 GUI 界面的 C++ 图形组件类

本文作者:nsfoxer

本文链接:https://www.cnblogs.com/nsfoxer/p/16317434.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   nsfoxer  阅读(15)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起