QSerialPortInfo undefined Type
-
Hi,
I try to use QSerialPortInfo, but I get the Issue that QSerialPortInfo is an undefined tpye.
Q_FOREACH(QSerialPortInfo port, QSerialPortInfo::availablePorts()) { qDebug() << "Port: " << port.portName(); }
Yes, I added serialport qo the .pro
Any Ideas why it doesn't work?
-
@Gh0stShell
Do you mean that you failed to#include <QSerialPortInfo>
into your source file? "undefined tpye" at compile or at link time? -
@macfanpl said in QSerialPortInfo undefined Type:
qt IDE should autoadd respective include directive.
And please tell us how Qt Creator will know what
include
directive to use?Let's say that I wrote a super-duper serial port information class that coincidentally is named
QSerialPortInfo
BUT I decided my .h file to be namedSerialComms
... so what Qt Creator will do? -
@JonB Yes, I really forgot to #include <QSerialPortInfo>. But as @macfanpl said Qt automatically added it.
But it was a good help to see what the problem is. Qt autoadded it like
#include <QtSerialPort/QSerialPort>
.
I did split it up to
#include <QtSerialPort>
and
#include <QSerialPort>
and now it seems to work. So the Problem was a mix of me forgetting to import and Qt to import it not the right way. I think...Thank you