Use different source codes based on different versions in Qt

Source: Internet
Author: User

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

 
 
  1. #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0))  
  2. // …  
  3. #endif 

The qmake syntax for this syntax is

Condition {

... Action 1...

} Else {

... Executed Action 2...

}

Therefore, you can use

 
 
  1. greaterThan(QT_MAJOR_VERSION, 4)|equals(QT_MAJOR_VERSION,4){  
  2.     greaterThan(QT_MINOR_VERSION, 5)|equals(QT_MINOR_VERSION, 5){   
  3.     message("bla,bla,bla ....")   
  4.     }   
  5. }else{   
  6.     message("pla,pla,pla ....")   
  7. }  

However, it should be noted that greaterThan and equals are not published in the qmake code. For details, see the source code of qmake.

 
 
  1. qt/qmake/project.cpp  
  2. if(!qmake_test_functions) {   
  3. qmake_test_functions = new QMap;   
  4. qmake_test_functions->insert("requires", T_REQUIRES);   
  5. qmake_test_functions->insert("greaterThan", T_GREATERTHAN);   
  6. qmake_test_functions->insert("lessThan", T_LESSTHAN);   
  7. 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.

Related Article

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.