QT Foundation (v) QT Engineering Pro file template variable use

Source: Internet
Author: User
Tags qt designer

qt Engineering Pro File template variables (templates) template variables Tell Qmake What kind of makefile is generated for this application. Here are the options to use:

    • App-Build an app for makefile. This is the default value, so if the template is not specified, this will be used.

    • Lib-Create a library of makefile.

    • Vcapp-Create a Visual Studio project file for an application.

    • Vclib-Create a Visual Studio project file for a library.

    • Subdirs-This is a special template that creates a makefile that can enter a specific directory and generate makefile for a project file and call make for it.

"App" template

The "app" template tells Qmake to generate a makefile for building an application. When using this template, the following qmake system variables are recognized. You should use them in your. Pro files to specify specific information for your application.

    • HEADERS-a list of all header files in the application.

    • SOURCES-a list of all source files in the application.

    • FORMS-a list of all. ui files (generated by the QT designer ) in the application.

    • Lexsources-a list of all the lex source files in the application.

    • Yaccsources-a list of all YACC source files in the application.

    • TARGET-the name of the executable application. The default value is the name of the project file. (If an extension is required, it is automatically added.) )

    • DESTDIR-the directory where the executable program target is placed.

    • Defines-the list of additional preprocessor definitions required by the application.

    • Includepath-the list of additional include paths required by the application.

    • Dependpath-The search path that the application relies on.

    • VPATH-Search path to find supplemental files.

    • Def_file-Only Windows needs: the. def file that the application wants to connect to.

    • Rc_file-only Windows requires: The application's resource file.

    • Res_file-Only Windows needs: The resource file that the application wants to connect to.

You only need to use system variables that you already have values for, for example, if you don't need any extra includepath, then you don't need to specify it,qmake will provide default values for the desired. For example, an instance project file might look like this:

TEMPLATE = App
DESTDIR = C:\helloapp
HEADERS + = Hello.h
SOURCES + = Hello.cpp
SOURCES + = Main.cpp
Defines + = Qt_dll
CONFIG + = qt warn_on Release

If the entry is single-valued, such as template or destination directory, we use "=", but if it is a multivalued entry, we use "+ =" to add an existing entry for this type. Using "=" replaces the original value with the new value, for example, if we write defines=qt_dll, all other definitions will be deleted.

"Lib" template

The "Lib" template tells Qmake to generate makefile for building a library. When using this template, there is a VERSION that is supported in addition to the system variables mentioned in the "app" template. You need to use them in. Pro files that specify specific information for the library.

    • Version-the revision number of the target library, for example, 2.3.1.

"Subdirs" template

The "subdirs" template tells Qmake to generate a makefile that can go into a specific subdirectory and generate makefile for the project file in the directory and call make for it.

In this template, only one system variable subdirs can be identified. This variable contains the list of subdirectories to be processed that contain the project files. The name of the project file is the same as the subdirectory, so qmake can find it. For example, if the subdirectory is "MyApp", then the project file in this directory should be called Myapp.pro.

Config variable

The configuration variable specifies the options to be used by the compiler and the libraries that need to be connected. You can add anything in the configuration variable, but only the following options can be qmake recognized.

The following options control which compiler flags are used:

    • Release-the application will be linked in release mode. If "Debug" is specified, it will be ignored.

    • Debug-The application will be connected in debug mode.

    • WARN_ON-the compiler will output as many warning messages as possible. If "Warn_off" is specified, it will be ignored.

    • Warn_off-the compiler will output as few warning messages as possible.

The following options define the type of library/application to be connected:

    • QT-the application is a QT application, and the QT library will be connected.

    • Thread-The application is a multithreaded application.

    • X11-The application is an X11 application or library.

    • Windows-only for the app Template: The application is a window application under Windows.

    • Console-for the app template only: The application is a console application under Windows.

    • DLL-only for "Lib" Templates: Libraries are a shared library (DLL).

    • Staticlib-only for "Lib" Templates: library is a static library.

    • Plugin-only for "Lib" Templates: Libraries are a plug-in that will make DLL options effective.

For example, if your application uses the QT library and you want to connect it as a multithreaded application that can be debugged, your project file should have the following line:

CONFIG + = qt Thread Debug

Note that you must use "+ =", do not use "=", otherwise qmake will not be able to correctly use the settings of the QT, such as not to get the type of the compiled QT library


QT Foundation (v) QT Engineering Pro file template variable use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.