Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. [Solved]obdii.cpp:118: error: undefined reference to

[Solved]obdii.cpp:118: error: undefined reference to

Scheduled Pinned Locked Moved C++ Gurus
6 Posts 2 Posters 3.1k 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.
  • J Offline
    J Offline
    jonesy29847
    wrote on last edited by
    #1

    Thank you in advance for your help.

    I receige the following message when I compile.

    obdii.h
    @#ifndef OBDII_H
    #define OBDII_H

    #include <QtWidgets/QtWidgets>
    #include <QtWidgets/QDialog>
    #include <QtCore>
    #include <QtGui>

    class QLabel;
    class QLineEdit;
    class QPushButton;
    class QTreeViewWidget;
    class QListWidget;

    class obdiiDlg : public QDialog
    {
    Q_OBJECT

    void AddRoot(QString Name, QString Description);
    void AddChild(QTreeView *parent, QString Name, QString Description);
    

    public:
    obdiiDlg(QWidget *parent = 0);

    signals:
    void getDTC(const QString &str, Qt::CaseSensitivity cs);
    void getPIDData(const QString &str, Qt::CaseSensitivity cs);
    void clearMIL(const QString &str, Qt::CaseSensitivity cs);
    void printReport(const QString &str, Qt::CaseSensitivity cs);
    void goOnline(const QString &str, Qt::CaseSensitivity cs);
    void sendData(const QString &str, Qt::CaseSensitivity cs);

    private slots:
    void btnGetDTCClicked();
    void btnGetPIDDataClicked();
    void btnClearMILClicked();
    void btnGoOnlineClicked();
    void btnSendDataClicked();
    void btnPrintClicked();

    private:
    QLabel *lblMessage;
    QLabel *lblPIDSelection;

    QLabel *lblPIDData;
    QTreeWidget *treePIDData;
    QPushButton *btnGetDTC;
    
    QLabel *lblSendData;
    QLineEdit *editSendData;
    
    QLabel *lblReadData;
    QLineEdit *editReadData;
    

    };
    #endif // OBDII_H
    @

    @#include <QtGui>
    #include "obdii.h"

    obdiiDlg::obdiiDlg(QWidget *parent)
    :QDialog(parent)
    {
    lblMessage = new QLabel(tr("Message"));

    lblPIDData = new QLabel(tr("PID data"));
    treePIDData = new QTreeWidget;
    lblPIDData->setBuddy(treePIDData);
    
    connect(btnGetDTC, SIGNAL(clicked()), this, SLOT(btnGetDTCClicked()));
    
    QVBoxLayout *leftLayout = new QVBoxLayout;
    leftLayout->addWidget(lblPIDData);
    leftLayout->addWidget(treePIDData);
    
    QHBoxLayout *mainLayout = new QHBoxLayout;
    mainLayout->addLayout(leftLayout);
    
    setLayout(mainLayout);
    setWindowTitle("OBDII");
    setLayout(mainLayout);
    

    }

    main.cpp
    #include <QtWidgets/QApplication>

    #include "obdii.h"

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    obdiiDlg *dialog = new obdiiDlg;
    dialog->show();
    a.exec();
    }
    @

    obdii.pro
    @HEADERS +=
    obdii.h

    FORMS +=

    SOURCES +=
    obdii.cpp
    main.cpp

    QT += widgets

    @

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      From the code you posted, the problem is that you don't implement any of the slots from the class.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jonesy29847
        wrote on last edited by
        #3

        Are you saying that if I define a slot in a class, I must also define the function?

        Are there 'cliff notes' for using classes?

        Thanks

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Yes, you must implement the slots, only signals have no implementation.

          "Signals & Slots documentation":http://qt-project.org/doc/qt-4.8/signalsandslots.html

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jonesy29847
            wrote on last edited by
            #5

            You rock! How do I mark a post as solved
            I will get much use out of this forum.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              :)

              You just have to edit your first post and update the title

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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