Qmake is an easy-to-use tool used to create makefile Trolltech for development projects on different platforms. Qmake simplifies the generation of makefile. Therefore, to create a makefile, you only need a file with only a few lines of information. Qmake can be used by any software project, regardless of whether it is written using Qt, although it contains additional features for supporting Qt development.
Qmake generates makefile based on the information such as a project file. Project files can be generated by developers. Project files are usually simple, but they are perfect if needed. You do not need to modify the project file. qmake can also generate a project for Microsoft Visual Studio. As we all know, qmake does not provide
- #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0))
- // …
- #endif
The qmake syntax for this syntax is
Condition {
... Action 1...
} Else {
... Executed Action 2...
}
Therefore, you can use
- greaterThan(QT_MAJOR_VERSION, 4)|equals(QT_MAJOR_VERSION,4){
- greaterThan(QT_MINOR_VERSION, 5)|equals(QT_MINOR_VERSION, 5){
- message("bla,bla,bla ....")
- }
- }else{
- message("pla,pla,pla ....")
- }
However, it should be noted that greaterThan and equals are not published in the qmake code. For details, see the source code of qmake.
- qt/qmake/project.cpp
- if(!qmake_test_functions) {
- qmake_test_functions = new QMap;
- qmake_test_functions->insert("requires", T_REQUIRES);
- qmake_test_functions->insert("greaterThan", T_GREATERTHAN);
- qmake_test_functions->insert("lessThan", T_LESSTHAN);
- qmake_test_functions->insert("equals", T_EQUALS);
Summary: The content of using different source code in the Qt project file is described based on different versions. I will briefly introduce it and hope it will help you.