Force QT in .pro file

I am looking for a way to force the use of a specific version of QT in a .pro file. To be more specific, I would like to force qmake use only QT 5.x version with my project instead of QT 4.x and QT 5.x

Is there any way to do this?

PS: I do not ask to stop / stop the compilation process (aka check the QT version, and if below 5.x just throw qFatal / equivalent). I am looking for a way to choose which version to use when creating a Makefile with qmake

+4
source share
3 answers

You may throw an error if the user starts qmake with the version that you do not want to use. eg:

 lessThan(QT_MAJOR_VERSION, 5): error("requires Qt 5") 
+5
source

I really doubt that you can do this. qmake is part of the framework and comes with libraries. When you say Qt of specific verion , you only mean libraries, but that is not true.

To use a specific version of Qt, you need to run another version of qmake . If you use QtCreator - you should select it in the project settings, if not - enter the absolute path to the qmake file. You can find out which version of Qt qmake use, you can enter qmake --version .

+4
source

As Amartel wrote in his answer, you must specify the correct version of qmake (check it by typing qmake --version in the console)

Your project may have been created using the wrong qmake executable, and some files will not be deleted even if you select nmake clean or clean it.

Check if there is a Makefile in the source tree after cleaning (these files usually contain the path to the used qt version and, if they are not restored correctly, point to the wrong Qt version).

+1
source

Source: https://habr.com/ru/post/1479339/


All Articles