How will defining operator<< for a totally unrelated class help solve the problem? The compiler is complaining because QSerialPortInfo::availablePorts() returns QList<QSerialPortInfo> and when you try to output this list through qDebug(), it can't find a match for "QDebug operator<<( QDebug, const QSerialPortInfo & )".
When QDebug tries to serialize QList<T> (where in your case, T == QSerialPortInfo), it will take each member of the list and apply operator<<( QDebug, const T & ) to that member. This operator doesn't exist in the Qt library, so you'll have to write it. You have basically done that inside your foreach() loop.
On the other hand, if all you are asking for in the first qDebug() statement in line 40 is the count of the available ports, then add ".size()" to the end of "QSerialPortInfo::availablePorts()".




Reply With Quote

Bookmarks