5

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?

MrLeeh
  • 5,321
  • 6
  • 33
  • 51
Mahdi_Nine
  • 14,205
  • 26
  • 82
  • 117
  • 1
    Did you actually build and install the module? Read [this](http://qt-project.org/wiki/QtSerialPort). – thuga Jun 20 '13 at 06:15

3 Answers3

7

Try including #include <QtSerialPort/QSerialPort> instead of
#include <QSerialPort>, that worked for me

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
5

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/

cloose
  • 916
  • 5
  • 18
  • I have installed QT 5.1.1 and I still do not see that module. Was it removed in QT 5.1.1? – CodePoet Sep 20 '13 at 17:47
  • I'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](http://qt-project.org/doc/qt-5.1/qtserialport/qtserialport-index.html) for more information. – cloose Sep 24 '13 at 13:28
  • 2
    I 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. – CodePoet Sep 24 '13 at 20:15
3

try including

#include <QtSerialPort/QSerialPort>

also update your project.pro file, add this flag

QT += serialport

after that clean , qmake , rebuild the project

user889030
  • 4,353
  • 3
  • 48
  • 51
  • 1
    I 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? :) – hyde Jan 14 '20 at 13:31
  • 2
    ya 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. – user889030 Jan 14 '20 at 16:27