当前位置:网站首页>1. Project preparation and creation
1. Project preparation and creation
2022-06-27 02:16:00 【Endless character】
Catalog
One 、 Environment building
1 - Qt install
- Qt edition :Qt 5.9.8
- Qt Development environment construction : Reference address -> https://blog.csdn.net/qq23001186/article/details/125469147
2 - FFmpeg install
Two 、Qt Project composition and management
- Qt Project management window : stay Qt Creator Click... In the left toolbar “ edit ” Button , You can enter the project management window ;Qt Creator You can open multiple projects , But there is only one activity , The active project name is bold
- Under the project name node , Groups manage various source files , The files and groups are as follows
- xxx.pro file : It's a project management document , Including some settings for the project
- Headers grouping : Under this node are all header files in the project (.h)
- Sources grouping : Under this node are all items in the project C++ Source file (.cpp)
- Resources grouping : Various resource files in the project under this node , Such as QML file , Icon ( picture ) file , Translation of documents, etc ; Use qrc File load resource
3、 ... and 、.pro Introduction to project documents
- .pro File Comments : Use
#Annotate
| keyword | paraphrase |
|---|---|
TEMPLATE | Appoint qmake What kind of... Is generated for this application makefile |
QT | Specify the... To use Qt modular ( The default is core gui, Corresponding to QtCore and QtGui modular ) |
CONFIG | The configuration variable specifies the options to be used by the compiler and the libraries to be connected |
TARGET | Specify the base file name of the executable or library , It doesn't contain any extensions 、 Prefix or version number ( The default is the current directory name ) |
DEFINES | List of additional preprocessor definitions required by the application |
SOURCES | List of all source files in the application |
HEADERS | In the application C++ The header file (.h) |
FORMS | All... In the application .ui file ( from Qt Designer generation ) A list of |
DESTDIR | The directory where the executable object is placed |
INCLUDEPATH | Additional list of include paths required by the application |
DEPENDPATH | The search path the application depends on |
VPATH | Search path for supplementary files |
DEF_FILE | Only Windows need : What the application wants to connect to .def file |
RC_FILE | Only Windows need : Resource files for the application |
RES_FILE | Only Windows need : The resource file to which the application will connect |
- TEMPLATE Key type
| TEMPLATE Keyword content | paraphrase |
|---|---|
app | Build an application of makefile. This is the default , So if the template is not specified , This will be used . |
lib | Build a library of makefile. When using this template , except “app” System variables are mentioned in the template , One more VERSION Is supported by . You need to specify specific information for the library .pro Use them in files .VERSION - Version number of the target library , such as ,2.3.1 |
vcapp | Build an application of Visual Studio Project documents |
vclib | Build a library of Visual Studio Project documents |
subdirs | This is a special template , It can create a directory that can enter a specific directory and generate... For a project file makefile And call... For it make Of makefile. There is only one system variable in this template SUBDIRS Can be identified . This variable contains the list of subdirectories containing project files to be processed . The name of this project file is the same as the subdirectory , such qmake You can find it . for example , If it's in the subhead “myapp”, So the project file in this directory should be called myapp.pro |
- CONFIG Key type : Configuration variables specify the options to be used by the compiler and the libraries to be connected . Anything can be added to the configuration variable , But only the following options can be qmake distinguish
| CONFIG Keyword content | paraphrase |
|---|---|
release | The application will use release Pattern serialization . If “debug” To be designated , It will be ignored |
debug | The application will use debug Pattern serialization |
warn_on | The compiler will output as many warnings as possible . If “warn_off” To be designated , It will be ignored |
warn_off | The compiler will output as few warnings as possible |
qt | The application is a Qt Applications , also Qt The library will be connected |
thread | An application is a multithreaded application |
x11 | The application is a X11 Application or library |
windows | Used only for “app” Templates : The application is a Windows Next window application |
console | Used only for “app” Templates : The application is a Windows The console application under |
dll | Used only for “lib” Templates : A library is a shared library (dll) |
staticlib | Used only for “lib” Templates : A library is a static library |
plugin | Used only for “lib” Templates : Library is a plug-in , This will make dll Options to take effect |
Four 、Qt Meta object system
- Qt Introduction to meta object system :Qt Meta object system (Meta-Object System) Provides signals and slot base addresses for communication between objects 、 Runtime type information and dynamic attribute system
- Qt The meta object system consists of the following three foundations
- QObject Class is the base class of all classes that use the meta object system
- In a class private Partial declaration Q_OBJECT macro , Enables classes to use the properties of meta objects , Such as dynamic properties 、 Signal and slot
- MOC( Meta object editor ) For each QObject Subclasses of provide the necessary code to implement the characteristics of the meta object system ; When building a project ,MOC Tool reading C++ Source file , When it finds that the class definition has Q_OBJECT Macro time , It will generate another class with meta object support code for this class C++ Source file , The generated source file is compiled and connected with similar implementation files
5、 ... and 、Qt Basic modules
| modular | describe |
|---|---|
| Qt Core | QtCore Modules are all based on Qt The foundation of the application , Core non graphical classes used by other modules . Provides a mechanism for communication between signals and slots , Concurrency and multithreading , Containers , The event system , Plug ins and I/O facilities |
| Qt GUI | The most important GUI modular . Graphical user interface (GUI) The base class of the component . Include OpenGL |
| Qt widgets | Used to build GUI Interface C++ Graphics component class , Include based on GUI Typical widget classes for applications and QSceneGraph class . stay Qt 5 In the from QtGui Separate from |
| Qt Multimedia | Audio 、 video 、 Broadcast and camera functions |
| Qt Multimedia Widgets | Realize the multimedia function and get the interface component class |
| Qt Network | Use a simpler and lighter class for network programming |
| Qt QML | Qt QML The module is used for QML and JavaScript Language |
| Qt Quick | This module is used to QML2 Compiling GUI Applications . Declarative framework for building highly dynamic applications with custom user interfaces |
| Qt Quick Controls | Offer lightweight QML type , For desktop 、 Embedded and mobile devices create high-performance user interfaces . These types have a simple style architecture and are very efficient |
| Qt Quick Dialogs | For from Qt Quick The type with which the application creates and interacts with the system dialog |
| Qt Quick Layouts | Used in Qt Quick Arrange the layout of the project in |
| Qt SQL | Include use SQL Classes for database integration |
| Qt Test | For unit testing Qt Application and library classes . Be careful : The binary compatibility guarantee does not apply to Qt test . however , It will remain source compatible |
6、 ... and 、 Project new
1 - New projects
- New projects







2 - Use vs Open the project
Use vs Open the project
- qml Of ui Some suggestions are in qt In the development
- For debugging, you can choose vs, Easier to debug
newly build bat File generation vs Project documents :
qmake -tp vc DemoProl.pro( Use qmake Based on the current .pro File generation is suitable for Visual Stdio Engineering documents of )

win10 Run under bat Set up : Add the variable name to the system environment variable ->
%path%, A variable's value ->C:/windows/system32function GeneVS.bat Report errors :

Set up cl.exe Environment variables of : Search the computer cl.exe; My computer path is
D:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64; In environment variable -> System -> PATH Add a path toUse VS Open the project file .vcxproj

3 - QT Inheritance system
QGuiApplication app(argc, argv);: stay main.cpp Can be seen in app yes QGuiApplication class , View source discovery QGuiApplication Inherit QCoreApplication, And uses macros Q_OBJECT; and QCoreApplication Inherited QT Base class of QObject


QQmlApplicationEngine engine:QQmlApplicationEngine Inherited QQmlEngine, And also uses macros Q_OBJECT;QQmlEngine Inherited QJSEngine;QJSEngine In the end, he inherited it QT Base class of QObject


4 - vs Run the project
- The following error reporting solutions : project -> Retarget the solution
1>------ Build started : project : DemoProl, To configure : Debug x64 ------
1>D:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.Cpp.WindowsSDK.targets(46,5): error MSB8036: Can't find Windows SDK edition 8.1. Please install the required version of Windows SDK Either in the project property page or by right clicking the solution and selecting “ Retarget the solution ” To change the SDK edition .
1> The build project is complete “DemoProl.vcxproj” The operation of - Failure .
========== Generate : success 0 individual , Failure 1 individual , newest 0 individual , skip 0 individual ==========

5 - vs Set the default encoding to UTF-8
- Why do I need to change it to UTF-8: because Qt The default code in is UTF-8, And most of the others IDE All codes are UTF-8; and VS The default encoding for is GB2312
- vs Set the default encoding to UTF-8: Tools -> Expansion and update -> online -> Search for
force UTF-8(No BOM)-> close vs It will be installed automatically after -> Just reopen the project
- An error message may appear after modifying the character encoding :warning C4819: The file contains cannot be in the current code page (936) The characters represented in . Please save this file as Unicode Format to prevent data loss
Solution :
1. Modify character encoding format ( recommend )
Visual Studio Provide advanced save options , It can specify the encoding specification of a specific code file and the newline character used at the end of the line .
stay Visual Studio 2017 in , This command is not displayed by default in “ file ” The menu . You need to set it manually , To display the command .
The operation method is as follows :
(1) single click “ Tools ”|“ Customize ” command , eject “ Customize ” Dialog box .
(2) single click “ command ” label , Get into “ command ” tab .
(3) stay “ menu bar ” In the drop-down list , choice “ file ” Options .
(4) single click “ Add command ” Button , eject “ Add command ” Dialog box .
(5) stay “ Category ” In the list , choice “ file ” Options ; stay “ command ” In the list , choice “ Advanced save options ” Options .
(6) single click “ determine ” Button , close “ Add command ” Dialog box .
(7) Choose “ Control ” In the list “ Advanced save options ” Options , single click “ Move upward ” perhaps “ Move down ” Button , Adjust the position of the command .
(8) single click “ close ” Button , complete “ Advanced save options ” Add operation of command .
(9) open “ file ” Under the menu “ Advanced save options ”, Set encoding Unicode(utf-8 Signed )- code page 65001
边栏推荐
猜你喜欢
随机推荐
Flink學習2:應用場景
Oracle/PLSQL: Ltrim Function
使用命令行安装达梦数据库
Oracle/PLSQL: From_ Tz function
Memcached basics 13
Summer planning for the long river
Oracle/PLSQL: Lower Function
Oracle/PLSQL: Soundex Function
Memcached basics 15
Oracle/PLSQL: CharToRowid Function
Oracle/PLSQL: HexToRaw Function
学习太极创客 — MQTT(九)ESP8266 同时订阅和发布 MQTT 消息
jwt的认证流程和使用案例
What if asreml-r does not converge in operation?
解决cherry pick提交报错问题
Getting started with bluecms code auditing
Microsoft365开发人员申请
Learn Tai Chi Maker - mqtt (VI) esp8266 releases mqtt message
正则表达式:语法
Oracle/PLSQL: NumToYMInterval Function








