Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]Qt 5.1 available serial port list
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Qt 5.1 available serial port list

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 10.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mikecurl91
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mikecurl91
      wrote on last edited by
      #2

      Missed "QT += serialport" in .pro file

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved