zoukankan      html  css  js  c++  java
  • 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++ 图形组件类
  • 相关阅读:
    字符串 CSV解析 表格 逗号分隔值 通讯录 电话簿 MD
    Context Application 使用总结 MD
    RxJava RxPermissions 动态权限 简介 原理 案例 MD
    Luban 鲁班 图片压缩 MD
    FileProvider N 7.0 升级 安装APK 选择文件 拍照 临时权限 MD
    组件化 得到 DDComponent JIMU 模块 插件 MD
    gradlew 命令行 build 调试 构建错误 Manifest merger failed MD
    protobuf Protocol Buffers 简介 案例 MD
    ORM数据库框架 SQLite 常用数据库框架比较 MD
    [工具配置]requirejs 多页面,多入口js文件打包总结
  • 原文地址:https://www.cnblogs.com/nsfoxer/p/14353837.html
Copyright © 2011-2022 走看看