Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Ubuntu QT

Ubuntu QT

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
2 Posts 2 Posters 310 Views
  • 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.
  • _ Offline
    _ Offline
    _volterra
    wrote on last edited by
    #1
    1. Where arei definition for QT include paths in QTCreator GUI ?
      2.When try example " Qt Programming - Serial Port " from YouTube i get :

    :-1: error: CMakeFiles/FirstAppl.dir/mainwindow.cpp.o: in function MainWindow::on_btnPortsInfo_clicked()': /home/pache/FirstAppl/mainwindow.cpp:19: error: undefined reference to QSerialPortInfo::availablePorts()'
    :-1: error: /home/pache/FirstAppl/mainwindow.cpp:20: undefined reference to QSerialPortInfo::portName() const' :-1: error: CMakeFiles/FirstAppl.dir/mainwindow.cpp.o: in function void std::_Destroy<QSerialPortInfo>(QSerialPortInfo*)':
    /usr/include/c++/9/bits/stl_construct.h:98: error: undefined reference to `QSerialPortInfo::~QSerialPortInfo()'
    :-1: error: collect2: error: ld returned 1 exit status
    :-1: error: ninja: build stopped: subcommand failed.

    mainwindow.h is :

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QMainWindow>
    #include <QtSerialPort/QSerialPortInfo>
    #include <QtSerialPort/QSerialPort>

    QT_BEGIN_NAMESPACE
    namespace Ui {
    class MainWindow;
    }
    QT_END_NAMESPACE

    class MainWindow : public QMainWindow
    {
    Q_OBJECT
    public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    private slots:
    void on_btnPortsInfo_clicked();
    private:
    Ui::MainWindow *ui;
    };
    #endif // MAINWINDOW_H

    and mainwindow.cpp

    #include "mainwindow.h"
    #include "./ui_mainwindow.h"
    #include <QDebug>

    MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    void MainWindow::on_btnPortsInfo_clicked()
    {
    foreach (auto &port, QSerialPortInfo::availablePorts()){
    qDebug() << port.portName() ;
    }
    }

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Please properly format your code so others can read it.
      When you use a class/function from a library, you also have to link against it. You are using the QSerialPortInfo class so you also must link against the library which contains it as written in the documentation.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1

      • Login

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