I downloaded Qt 5 and tried to create my project. Now, to add a widget to the QT variable, projects are required, but this causes a warning with the old version:
MESSAGE About the project: warning: unknown QT: widgets
A simple solution seems to add a simple check:
equals( $$QT_MAJOR_VERSION, 5 ) { message(" ================ QT 5 ================ ") QT += widgets } else { message(" ================ QT 4 ================ ") }
This did not work (QT 4 is printing). It is true that equals is not part of the qmake function reference , but contains is. So, tried with:
contains( $$QT_MAJOR_VERSION, 5 ) { message(" ================ QT 5 ================ ") QT += widgets } else { message(" ================ QT 4 ================ ") }
but that didn't work either. Various other combinations, such as contains ("$$ QT_MAJOR_VERSION", "5"), do not work.
It is assumed that the value of $$ QT_MAJOR_VERSION is 4 or 5 using a string like:
message( $$QT_MAJOR_VERSION )
Setting up a local variable and testing its value in this way does not work.
The conclusion of all this is that I do not understand anything fundamental in the qmake mechanism. So how to compare a variable with a value in the qmake.pro file?
Nicu tofan
source share