当前位置:网站首页>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)
:同理语言的读、写、更改也会关联
边栏推荐
- Pytorch model
- Pytorch main modules
- Embedded design and development project - liquid level detection and alarm system
- Talk about exception again -- what happens when an exception is thrown?
- 2.01 backpack problem
- Prediction of red wine quality by decision tree
- PCB懂王,你是吗?我不是
- Other domestic mobile phones failed to fill the vacancy of Huawei, and apple has no rival in the high-end mobile phone market
- Inftnews | technology giants accelerate their march into Web3 and metauniverse
- (原创)【MAUI】一步一步实现“悬浮操作按钮”(FAB,Floating Action Button)
猜你喜欢
Oracle 云基础设施扩展分布式云服务,为组织提供更高的灵活性和可控性
1015. picking flowers
Writing skills of resume
Why do more and more users give up swagger and choose apifox
Luogu_ P1303 A*B Problem_ High precision calculation
(original) [Maui] realize "floating action button" step by step
Kubernetes 深入理解kubernetes(一)
5A同步整流芯片 20V转12V2A/5V4.5A大电流 24W大功率同步整流芯片 大电流降压IC FS2462
CVPR再起争议:IBM中稿论文被指照搬自己承办竞赛第二名的idea
2.01 backpack problem
随机推荐
Special test for cold and hot start of app
PHP根据年月获取月初月末时间
Websocket automatically disconnects in 1 minute
其他国产手机未能填补华为的空缺,苹果在高端手机市场已无对手
嵌入式设计与开发项目-液位检测告警系统
Mysql database literacy, do you really know what a database is
CodeBlocks MinGW installation configuration problem
Action interprets value. The chairman of chenglian Youpin Han attended the Guangdong Yingde flood fighting donation public welfare event
thinkphp6 多级控制器目录访问解决方法
PHP gets the number of digits and replaces it with the specified mantissa
Notes on the use of official jeecg components (under update...)
The difference between align items and align content
The English translation of heartless sword Zhu Xi's two impressions of reading
Kubernetes' in-depth understanding of kubernetes (II) declaring organizational objects
Design artificial intelligence products: technical possibility, user acceptability and commercial feasibility
Prediction of red wine quality by decision tree
G1垃圾收集器中重要的配置参数及其默认值
You must configure either the server or JDBC driver (via the ‘serverTimezone‘ configuration property
Jerry's wif interferes with Bluetooth [chapter]
Mobile web training -flex layout test question 1