[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&#40;&#41;;
    

    }@

    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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.