当前位置:网站首页>3、项目的整体UI架构
3、项目的整体UI架构
2022-06-28 13:37:00 【无休止符】
一、MYPlayer.pro详解
MYPlayer.pro:记录了整个项目工程的设置,不建议随便修改
- 项目模板:建立一个应用程序的makefile
# Project Type
TEMPLATE = app
- QT引用模块
# Qt modules that are used by your project
QT += qml quick gui widgets multimedia opengl openglextensions
- 项目编译选项与库
# Project configuration and compiler options
CONFIG += qt warn_on c++11 rtti stl thread exceptions
- moc文件路径配置:moc 全称是 Meta-Object Compiler,也就是“元对象编译器”;编译之后就看到moc文件
- Qt 不是使用的“标准的” C++ 语言,而是对其进行了一定程度的“扩展”。这里我们从Qt新增加的关键字就可以看出来:signals、slots 或者 emit。所以有人会觉得 Qt 的程序编译速度慢,这主要是因为在 Qt 将源代码交给标准 C++ 编译器,如 gcc 之前,需要事先将这些扩展的语法去除掉。完成这一操作的就是 moc
- moc 全称是 Meta-Object Compiler,也就是“元对象编译器”。Qt 程序在交由标准编译器编译之前,先要使用 moc 分析 C++ 源文件。如果它发现在一个头文件中包含了宏 Q_OBJECT,则会生成另外一个 C++ 源文件。这个源文件中包含了 Q_OBJECT 宏的实现代码。这个新的文件名字将会是原文件名前面加上 moc_ 构成。这个新的文件同样将进入编译系统,最终被链接到二进制代码中去。因此我们可以知道,这个新的文件不是“替换”掉旧的文件,而是与原文件一起参与编译。另外,我们还可以看出一点,moc 的执行是在预处理器之前。因为预处理器执行之后,Q_OBJECT 宏就不存在了
# Directory where all intermediate objects and moc files should be placed
CONFIG(debug, debug|release) {
OBJECTS_DIR = ./tmp/debug
MOC_DIR = ./tmp/debug
} else {
OBJECTS_DIR = ./tmp/release
MOC_DIR = ./tmp/release
}
- 临时文件与编译器输出的资源文件路径
# Directory where all intermediate files from uic should be placed
CONFIG(debug, debug|release) {
UI_DIR = ./tmp/debug
} else {
UI_DIR = ./tmp/release
}
# Directory for Qt Resource Compiler output files
CONFIG(debug, debug|release) {
RCC_DIR = ./tmp/debug
} else {
RCC_DIR = ./tmp/release
}
- Debug和Release的生成路径
# Specifies where to put the target file
CONFIG(debug, debug|release) {
contains(QMAKE_TARGET.arch, x86_64) {
DESTDIR = $$_PRO_FILE_/../../../bin/debug/x64
} else {
DESTDIR = $$_PRO_FILE_/../../../bin/debug/x86
}
} else {
contains(QMAKE_TARGET.arch, x86_64) {
DESTDIR = $$_PRO_FILE_/../../../bin/release/x64
} else {
DESTDIR = $$_PRO_FILE_/../../../bin/release/x86
}
}
- 指定项目目标可执行的文件名:其中不包含任何的扩展、前缀或版本号(默认的是当前的目录名)
# Name of the target file
TARGET = MYPlayer
- 指定项目资源文件、code的编码
# Name of the resource collection files (qrc) for the target
RESOURCES += resource/MYPlayer.qrc
#RESOURCES += qml.qrc
# Codec configuration
CODECFORTR = UTF-8
CODECFORSRC = UTF-8
- 项目使用的jml和js文件
# Source files which contains strings for i18n
lupdate_only {
SOURCES += resource/ui/qml/*.qml \ resource/ui/qml/*.js } - 翻译文件:可以打开resource/ui/translation/MYPlayer_zh_CN.ts文件查看,支持中英文的翻译
# Translation file path
TRANSLATIONS += ./resource/ui/translation/MYPlayer_zh_CN.ts

- 编译选项定义:QT_DEPRECATED_WARNINGS表示QT的某些功能被标记为过时的时候,编译器会发出警告
# 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). Refer to the documentation for the
# deprecated API to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
- 项目源文件
# Source files in the project
SOURCES += \
MYAudioPlay.cpp \
MYAudioThread.cpp \
MYDecode.cpp \
MYDecodeThread.cpp \
MYDemux.cpp \
MYDemuxThread.cpp \
MYResample.cpp \
MYVideoThread.cpp \
MYVideoOutput.cpp \
MYPlay.cpp \
main.cpp \
MainApp.cpp \
MYSubTitle.cpp \
- 项目头文件及包含文件路径
# Header files for the project
HEADERS += MainApp.h \
IVideoCall.h \
MYAudioPlay.h \
MYAudioThread.h \
MYDecode.h \
MYDecodeThread.h \
MYDemux.h \
MYDemuxThread.h \
MYResample.h \
MYVideoThread.h \
MYVideoOutput.h \
MYPlay.h \
MYSubTitle.h \
# Include path
INCLUDEPATH += ../../include
- 项目中使用的库文件
# Libaray path and libaray
CONFIG(debug, debug|release) {
contains(QMAKE_TARGET.arch, x86_64) {
LIBS += -L"$$PWD/../../lib/debug/x64/"
} else {
LIBS += -L"$$PWD/../../lib/debug/x86/"
}
# win32:LIBS += libqrencode.lib\ # libzint.lib
# unix:LIBS += -lqrencode\ # -lzint
} else {
contains(QMAKE_TARGET.arch, x86_64) {
LIBS += -L"$$PWD/../../lib/release/x64/"
} else {
LIBS += -L"$$PWD/../../lib/release/x86/"
}
# win32:LIBS += libqrencode.lib\ # libzint.lib
# unix:LIBS += -lqrencode\ # -lzint
}
win32:LIBS += avformat.lib\
avcodec.lib\
avutil.lib\
swresample.lib\
swscale.lib
- win32平台需要的rc文件:其他平台没有维护,默认即可
################################################################################
# Windows platform
win32 {
RC_FILE = win32/MYPlayer.rc
HEADERS += win32/targetver.h \
win32/resource.h
OTHER_FILES += win32/MYPlayer.rc
}
################################################################################
# Linux platform
linux {
}
################################################################################
# Mac OS X platform
macx {
}
二、Visual Stdio启动源代码
1 - 生成vs项目文件
- a.项目目录下新建GenerateVCProj.bat:
qmake -tp vc MYPlayer.pro
- b.运行GenerateVCProj.bat生成vs项目文件:使用vs打开MYPlayer.vcxproj文件即可启动vs项目

2 - vs下项目的目录结构说明

3 - MainApp.h启动类分析
- class MainApp : public QApplication:MainApp继承QApplication类,主要是为了完成程序初始化的工作,而这部分初始化工作的目的是为了在项目中建立界面管理的机制

- MainApp中加入了Q_OBJECT宏:这样之后我们的项目中就可以使用信号(signal)和槽(slot)机制

- MainApp的成员变量

- MainApp的成员方法

- 信号和槽

- QML属性-Q_PROPERTY:QML界面层的处理关联上逻辑层的复杂逻辑
Q_PROPERTY(int demoNum READ demoNum WRITE setDemoNum NOTIFY demoNumChanged):demoNum变量读、写、更改都会在界面上触发事件Q_PROPERTY(QString language READ language WRITE setLanguage NOTIFY languageChanged):同理语言的读、写、更改也会关联

边栏推荐
- Design artificial intelligence products: technical possibility, user acceptability and commercial feasibility
- How fragrant! The most complete list of common shortcut keys for pychar!
- StackOverflow 2022数据库年度调查
- 真香啊!最全的 Pycharm 常用快捷键大全!
- thinkphp6 多级控制器目录访问解决方法
- Jerry's wif interferes with Bluetooth [chapter]
- [understanding of opportunity -32]: Guiguzi - Dui [x ī] Five attitudes towards danger and problems
- Introduction to PWN (1) binary Basics
- Websocket automatically disconnects in 1 minute
- The difference between align items and align content
猜你喜欢
![(original) [Maui] realize](/img/76/d79b9cf4ed44870bb20a189315def9.jpg)
(original) [Maui] realize "floating action button" step by step

RSLO:自监督激光雷达里程计(实时+高精度,ICRA2022)

Solution to directory access of thinkphp6 multi-level controller

Recognize the startup function and find the user entry

Websocket automatically disconnects in 1 minute

Mobile web training day-1

The counter attack story of Fu Jie, a young secondary school student: I spent 20 years from the second undergraduate to the ICLR outstanding Thesis Award

行动诠释价值,城联优品韩董事长出席广东英德抗洪捐赠公益活动会

公司领导说,个人代码超10个Bug就开除,是什么体验?

StackOverflow 2022数据库年度调查
随机推荐
Hematemesis recommends 17 "wheels" to improve development efficiency
Electronic components distribution 1billion Club [easy to understand]
5A同步整流芯片 20V转12V2A/5V4.5A大电流 24W大功率同步整流芯片 大电流降压IC FS2462
Action interprets value. The chairman of chenglian Youpin Han attended the Guangdong Yingde flood fighting donation public welfare event
Google Earth Engine(GEE)——联合国粮农组织全球有机土壤面积(1992-2018年度)
RSLO:自监督激光雷达里程计(实时+高精度,ICRA2022)
Elastic box auto wrap demo
5A synchronous rectifier chip 20V to 12v2a/5v4.5a high current 24W high power synchronous rectifier chip high current step-down IC fs2462
栅格矢量数据的裁剪
MySQL multi table joint query
Centos7 - installing mysql5.7
全志V853芯片 如何在Tina V85x平台切换sensor?
How does Quanzhi v853 chip switch sensors on Tina v85x platform?
How to open an account on the flush? Is it safe
To be the Italian Islander? Liuqiangdong cashed out 6.6 billion yuan in two months and made a one-time 560million "emergency transfer" to buy the European maritime Palace
[codec] write H264 decoder (1) from scratch
为什么新的5G标准将为技术栈带来更低的 TCO
嵌入式设计与开发项目-液位检测告警系统
Jeecg 官方组件的使用笔记(更新中...)
Buuctf:[wustctf2020] plain