Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Terminal example [SOLVED]



  • Hey :)

    @void SettingsDialog::fillPortsInfo()
    {
    ui->serialPortInfoListBox->clear();
    static const QString blankString = QObject::tr("N/A");
    QString description;
    QString manufacturer;
    foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) {
    QStringList list;
    description = info.description();
    manufacturer = info.manufacturer();
    list << info.portName()
    << (!description.isEmpty() ? description : blankString)
    << (!manufacturer.isEmpty() ? manufacturer : blankString)
    << info.systemLocation()
    << (info.vendorIdentifier() ? QString::number(info.vendorIdentifier(), 16) : blankString)
    << (info.productIdentifier() ? QString::number(info.productIdentifier(), 16) : blankString);

        ui->serialPortInfoListBox->addItem(list.first(), list);
    }
    

    }
    @

    .pro file:
    @greaterThan(QT_MAJOR_VERSION, 4) {
    QT += widgets serialport
    } else {
    include($$QTSERIALPORT_PROJECT_ROOT/src/serialport/qt4support/serialport.prf)
    }

    TARGET = terminal
    TEMPLATE = app

    SOURCES +=
    main.cpp
    mainwindow.cpp
    settingsdialog.cpp
    console.cpp

    HEADERS +=
    mainwindow.h
    settingsdialog.h
    console.h

    FORMS +=
    mainwindow.ui
    settingsdialog.ui

    RESOURCES +=
    terminal.qrc
    @

    i says that "info" is not declared in scope?



  • Do you have
    @
    #include <QtSerialPort/QSerialPortInfo>
    @
    either in your .h or .cpp file?



  • He, c77asper.
    You started a post couple of days ago. I did send you some code (which I partly see in this post). Now please first set the previous post to [SOLVED] on your first post. Then you could continue with this one.
    The solution is probably what frankieFrank says. Include the proper classes and it should work.


Log in to reply