Specify minimum Qt version for QtCreator / QMake build - qt

I have a Qt project previously build using Qt 5.11. In order to support MacOS Mojave'e Dark Mode, I have updated the build to use Qt 5.13.2. This works perfectly, but the kit version is stored locally in the session settings not with the .pro project file.
I wish to enforce a minimum Qt kit version for the build, so that the build will abort if the correct kit version is not selected, ideally in the .pro file rather then the source code. How can I do that?

using versionAtLeast or lessThan you can check the Qt version. For instance:
equals(QT_MAJOR_VERSION, 5):lessThan(QT_MINOR_VERSION, 12) {
message("Cannot use Qt $${QT_VERSION}")
error("Use Qt 5.12 or newer")
}
or better:
!versionAtLeast(QT_VERSION, 5.12.0) {
message("Cannot use Qt $${QT_VERSION}")
error("Use Qt 5.12 or newer")
}

Related

Qt.labs.plarform is not installed only in release mode

I am using FileDialog from Qt.labs.platform 1.1 on win 10 in Qt creator, compilator I use is Desktop Qt 5.15.2. MinGW 64 bit.
In the debug mode is working everthing fine but when I change to release mode I get following error in from the compilator:
QQmlApplicationEngine failed to load component
qrc:/main.qml:6:1: module "Qt.labs.platform" is not installed
I tried things like clean and rebuild or restart the computer and also change the number of import version but nothing helps. Any ideas how to solve that, please?
Check folder, where you are building your release (where *.exe is generated):
does it contains some Qt's *.dll's?
If yes: there is two ways to resolve your problem:
Remove all Qt *.dll's and run your application from Qt Creator (then Qt Creator will take all Qt *.dll's from folder, where Qt is installed).
Or add all needed Qt *.dll's with correct folder structure to folder with your release *.exe (to do it for Windows release use windeployqt tool: https://doc.qt.io/qt-6/windows-deployment.html )
Why you have such error from the compilator?
Because you have some Qt *.dll's in your release folder (beside the *.exe), but not all needed (e.g. you have only Qt6Core.dll). So Qt Creator will find this dll and will try to find other dll's in your release folder. Qt Creator will not check its installation directory to get dll's.
But if you have no Qt *.dll's in your release folder, then Qt Creator will find them in its installation directory.

androiddeployqt can't find ant error, but works with Qt Creator

Qt 5.11. Mac OS X.
I'm trying to write automatic build script for Jenkins. Target platform: Android armv7.
androiddeployqt says me that it cannot find ant in PATH.
Yes, I did not install Ant.
But, it works somehow with Qt Creator. Qt Creator can build APK. Why so? It uses the same androiddeployqt, doesn't?
Do I really need to install ant (while Qt Creator does not need it)?
Qt Creator uses undocumented --gradle option. Add it to your command.

Build qt5.8 with desktop opengl option (ubuntu)

I built the sources of Qt5.8 with the option ./configure -opengl desktop
Then, I did a make and finally sudo make install. Now I changed the .profile file as pointed here: http://doc.qt.io/qt-5/linux-building.html
But I have a question: How can I start now qt creator ide?
It seems you're looking for qt creator, which isn't bundled in the qt sources and must be compiled separately, however if you want qt creator alongside with your new qt build, download the qt creator alone and install it, after that open the qt creator, go to Settings -> Build & Run -> Qt Versions , from there you can add new qt versions, just point to qmake which is located in your new qt installation (Probably /usr/local/qt5/bin/qmake) , now add a new kit via Kit's tab and then you can use your newly installed qt with qt creator.

Qt Creator 4.8.4. windows 7 - 64bit installation

I have some difficulties with QT, which I need for school for some GUI applications.
I have recently done these steps:
1) mingw-get-inst-20120426.exefrom SourceForge installed to C:\MinGW\ with default settings.
2) Qt libraries 4.8.4 for Windows (minGW 4.4, 317 MB) from QT Project installed to C:\Qt\ with default settings. Here an error occurs:
!!!There is a problem with your MinQW instalation
!!!g++ not found in c:\MinGW\bin\
!!!Do you still want to continue? Yes
I checked c:\MinGW\bin\ there is no such file
3) Qt Creator 2.6.0 for Windows (51 MB)also from QT installed to C:\Qt\gtcreator-2.6.0 with default settings
4) Run the QT IDE
5) Open project or create new project. Another error occurs here
!!!No valid kits fond.
Qt Creator uses the invalid kit Desktop to parse the project.
6) Open Options->Build & Run->Kits (But I don't know how should I set Kits and where to find them).
7) Can you also help me, how to set Qt version
(Options->Buid&Run->Qt Version)? Where do I find qmake.exe?
I also didn't find how to create GUI Application. There is no such option in New File or Project...
Thanks for help.
That is quite tricky ;)
Precompiled Qt (MinGW) is only win32 (not win64).
Precompiled Qt is compiled with MinGW-g++ 4.4 and won't work with other.
You have to download this one:
http://get.qt.nokia.com/misc/MinGW-gcc440_1.zip
//// Edit: With this version of MinGW, gdb won't work (it's not python-enabled). Although QtSDK is depracted (and you won't find it on qt-project.org), I highly recommend downloading this online installer and, during the selection of components mark only MinGW. It will come with folder named "pythongdb".
http://www.developer.nokia.com/info/sw.nokia.com/id/da8df288-e615-443d-be5c-00c8a72435f8/Qt_SDK.html
(You may need to register. It's free.)
////
Add "Compiler" by g++.exe
Add "Qt Version" by qmake.exe.
Add "Kit" with Compiler and Qt Version configured above. You can try to change debugger from CDB to GDB.
When you installed mingw, did you select the C++ compiler? It is not selected by default but you need it. Re-run the wizard and select that.
The kit is not valid because the C++ compiler cannot be found: try to install it first. If you still cannot setup this read the manual: http://doc-snapshot.qt-project.org/qtcreator-2.6/creator-targets.html. It is very complete.
qmake.exe is in *qt_directory*/bin/qmake.exe.
Try this out:
http://sourceforge.net/projects/mingw-w64/ (Since the mingw-w64 project on sourceforge.net is moving to mingw-w64.org i suggest to use mingw-w64.org)
It works for me.

Installing OpenGL for Qt

I just have installed Qt 4 on windows 7. I am now in a bit of a confusion
How do I get to install OpenGL so that it works with QT? Is there an installer for OpenGL?
Qt docs. say it has support for OpenGL, but when I include QTOpenGL and build, the compiler issues an error of "No such file or directory"
Thanks for the reply in advance!
Are you sure you followed this to the letter? You need to include <QtOpenGL> and set the QT += opengl option in your pro file.
What tool chain are you using? (Visual Studio, Qt Creator/g++) You need to specify somewhere in your project settings that you want to use the QtOpenGL module. This will result in a line in your .pro file similar to this:
QT = core gui opengl
This causes qmake to add the proper include path when invoking the compiler (I believe).
added the line QT += opengl to the .pro file

Resources