QtSerialPort QSerialPort no such file or directory
Solution 1
QtSerialPort module is not part of Qt 5.0. It was added to the upcoming release Qt 5.1.
You are looking at the documentation snapshot for the upcoming release Qt 5.1. See http://doc-snapshot.qt-project.org/qt5-stable/qtdoc/index.html.
The documentation for Qt 5.0 is here: http://qt-project.org/doc/qt-5.0/qtdoc/index.html.
If you still want to try QtSerialPort, the RC1 of Qt 5.1 was just released. You can download it here: http://download.qt-project.org/development_releases/qt/5.1/5.1.0-rc1/
Solution 2
Try including #include <QtSerialPort/QSerialPort>
instead of
#include <QSerialPort>
, that worked for me
Solution 3
try including
#include <QtSerialPort/QSerialPort>
also update your project.pro file, add this flag
QT += serialport
after that clean , qmake , rebuild the project
Comments
-
Mahdi_Nine almost 2 years
I use this tutorial : http://doc-snapshot.qt-project.org/qt5-stable/qtserialport/blockingmaster.html
But when I want to run it Qt Creator generates the following error:
error: Unknown module(s) in QT: serialport
When I hold mouse on
#include <QtSerialPort/QSerialPort>
it says:include no such file or directory
I use Qt
5.0.1
any idea? -
CodePoet over 10 yearsI have installed QT 5.1.1 and I still do not see that module. Was it removed in QT 5.1.1?
-
cloose over 10 yearsI'm not sure what you mean with "do not see it". The Qt Serial Port module is an add-on module. You need to activate it in your qmake project file and also include the header QtSerialPort. See the documentation for more information.
-
CodePoet over 10 yearsI meant that (for example) ...\5.1.1\msvc2012\include\QtSerialPort was not on my file system after installing QT 5.1.1. I have since re-installed and selected install Source Components (not selected by default) and the QtSerialPort is now available.
-
hyde over 4 yearsI think OP already had that line in the .pro file 6 and half years ago, when they asked the question, because they got the error
error: Unknown module(s) in QT: serialport
. And the other answer already contains that include thing. Did you notice how old this question was before answering? :) -
user889030 over 4 yearsya i notice it but i added the answer just for my logging purpose :) as today i was working with Qt serial and i included the lib but i was not aware of updating project.pro file with serialport flag due to which i was getting undefined errors to qtserial in build and then search a lot and found sample project on github where they have added serialport flag to pro file , so its most import thing , just including Qserialport will not work , pro file need to be updated.