Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED]Qt 5.1 available serial port list
-
This the code I'm using:
@#include <QGuiApplication>
#include <QtQml>
#include <QtQuick/QQuickView>
#include <QtSerialPort/QSerialPortInfo>
#include <QList>int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine(QUrl("qml/main.qml"));QList<QSerialPortInfo> list; QObject *topLevel = engine.rootObjects().value(0); QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel); if ( !window ) { qWarning("Error: Your root item has to be a Window."); return -1; } list = QSerialPortInfo::availablePorts(); <----------Error window->show(); return app.exec();
}@
but I've errors on the line indicated.
What is the problem? I'm trying to have simply the list of available ports on the pc!!
thanks
-
Missed "QT += serialport" in .pro file