How to include <QSerialPort> correctly?
-
I'm trying to include QSerialPort in a project. In the .pro file I've written this:
QT += core gui network greaterThan(QT_MAJOR_VERSION, 4) { QT += widgets serialport } else { CONFIG += serialport } CONFIG += c++11 ...
and so on.
After trying to build (or clean-qmake-rebuild) I get the message "Project ERROR: Unknown module(s) in QT: serialport".
I've also tried to find the file QSerialPort or QtSerialPort in the folder with all the Qt and there's no such file.
System: Windows 10, Qt Creator 4.14.0 based on Qt 5.15.2, MinGW... (don't remember the version but I've downloaded it today).
-
Hi
Thats a bit odd as its normally just
QT += serialport
As far as I know, that module is not optional and always installed.Are the examples there ?
-
@BurSer said in How to include <QSerialPort> correctly?:
System: Windows 10, Qt Creator 4.14.0 based on Qt 5.15.2, MinGW... (don't remember the version but I've downloaded it today).
INFO: Qt Creator is an IDE, it version is NOT relevant.
Which Qt Kit do you use to build your project (cf. Tools/Options/Kits)?
Edit:
CONFIG += serialport
does not make sense to me, it should beQT += serialport
My badCONFIG += serialport
is for Qt 4.x!!AFAIK,
QSerialPort
is not available with Qt 6.0, you have to use Qt 5.xx or wait until it is ported to Qt 6.x==> https://doc.qt.io/qt-6/whatsnew60.html#removed-modules-in-qt-6-0
-
ahh ofc. Its Qt6 :)
Good catch !