Omitting module in Qt pro file under Windows - qt

The Qt pro file begins as follows:
QT += core gui
QT += serialport
QT += displaysettings
This builds for my Hummingboard running Debian Linux. However displaysettings isn't available for Windows builds.I want to exclude this module from windows builds. I can exclude the function calls in the code from compiling. But adding displaysettings here causes an error.

Use:
QT += core gui
QT += serialport
!win32 {
QT += displaysettings
}
For more information read https://doc.qt.io/qt-5/qmake-language.html#scopes-and-conditions

The answer I accepted is good. Since then I've learned that displaysettings is very hardware dependent. It's available on my ARM processor running Armbian, but not on Linux running Intel and AMD processors. I wanted a solution that that works regardless of OS/processor combination. Thanks to Qt tech support I've used qtHaveModule like so:
qtHaveModule(displaysettings) {
QT += displaysettings
}
And this works great. More info # https://doc.qt.io/qt-5/qmake-test-function-reference.html#qthavemodule-name
Thank you eyllanesc for you answer.

Related

Specify minimum Qt version for QtCreator / QMake build

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")
}

How can I solve this 'no service found for - “org.qt-project.qt.mediaplayer”' error with a statically built Qt?

Hello in order to build static Qt for Windows, I followed the next article.
http://qt-project.org/wiki/How-to-build-a-static-Qt-for-Windows-MinGW
Using Qt vesion – 5.2.0. Operating System- Windows7.
The problem is that it says – no service found for – “org.qt-project.qt.mediaplayer” on building the project.
I searched the net, but no solution was useful. Maybe I’m not using them correctly because of some lack of knowledge of Qt infrastructure, but anyway if someone could give me some instructions of solving of this problem, I would really appreciate that.
I'm using statically Qt 5.2.1 OpenGL MinGW and had same problem (video wasn't playing with same "no service found"). In my case I solved the problem linking the static mediaplayer plugin (dsengine) in project. To do this I had to:
1) add in .pro file:
CONFIG += static
static:{
QTPLUGIN += dsengine
CONFIG += release
LIBS += -ldsengine
}
dsengine plugin is located in %QTDIR%/plugins/mediaservice/libdsengine.a
2) add somewhere in the code (around main.cpp):
#ifdef QT_STATIC
#include <QtCore/QtPlugin>
Q_IMPORT_PLUGIN(DSServicePlugin)
#endif

QT Creator _ITERATOR_DEBUG_LEVEL Miss match

I have linked my own static lib to my QT Creator project, the library has been compiled for both debug and release versions using VS 2010 Express. My QT Creator project uses VS 2010 compiler as well.
Now inside QT Creator whenever I try to build debug version of my project, I get multiple _ITERATOR_DEBUG_LEVEL link errors . What's more interesting the errors point to only those obj's that have some standard libraries included for example iostream or/and math .
When I build Release version of my QT Project everything is fine, and obviously if I un-link my library the debug version compiles fine as well .
Whats the proper way to compile my library so that I can use it inside QT Creator Debug mode ??
Many Thanks
Add following to Your pro file:
CONFIG( debug, debug|release ) {
# debug
LIBS += -lyour_lib_named
} else {
# release
LIBS += -lyour_lib_name
}

c++ Using PortAudio in Windows with Qt

I have managed to compile PortAudio on windows using MSYS.
this process has created 2 files: libportaudio-2.dll and libportaudio.dll.a
Now i want to link the libraries in QtCreator, but i can not since it requires a .lib file.
If anybody have experience of compiling and using libraries with MSYS under windows, your input is appreciated.
(Note: they are compiled using MindGW compiler. I dont want to compile it with Microsoft Visual Studio, since then i will have to compile QT)
to solve your problem is very simple. Here I report an example of a file. pros who need to use:
QT += core
QT -= gui
TARGET = mioTestAudio
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
LIBS += -lportaudio.dll <-------- this is the part you are interested
SOURCES += main.cpp

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