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?
-
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? -
Even when someone forgets about
includedirective, qt IDE should autoadd respectiveincludedirective. -
Even when someone forgets about
includedirective, qt IDE should autoadd respectiveincludedirective.@macfanpl said in QSerialPortInfo undefined Type:
qt IDE should autoadd respective include directive.
And please tell us how Qt Creator will know what
includedirective to use?Let's say that I wrote a super-duper serial port information class that coincidentally is named
QSerialPortInfoBUT I decided my .h file to be namedSerialComms... so what Qt Creator will do? -
@Gh0stShell
Do you mean that you failed to#include <QSerialPortInfo>into your source file? "undefined tpye" at compile or at link time?@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