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. Release/moc_Controller.cpp:-1: error: undefined reference to `Controller::handleResults(QString const&)'
Forum Updated to NodeBB v4.3 + New Features

Release/moc_Controller.cpp:-1: error: undefined reference to `Controller::handleResults(QString const&)'

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 309 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.
  • M Offline
    M Offline
    micha_eleric
    wrote on last edited by
    #1

    using code from https://doc.qt.io/qt-5/qthread.html, changed a few names, and split into .h and .cpp files, I get a moc file error.

    .h file:

    #ifndef CThreadCONTROLLER_H
    #define CThreadCONTROLLER_H
    
    #include <QObject>
    #include <QThread>
    
    class CThreadController : public QObject
    {
        Q_OBJECT
        QThread guiThread;
    public:
        // constructor
        CThreadController();
        // destructor
        ~CThreadController();
    
    public slots:
        void handleResults(const QString &);
    
    signals:
        void operate(const QString &);
    
    };
    
    #endif // CThreadCONTROLLER_H
    

    .cpp file:

    #include "CThreadController.h"
    #include "CGUI.h"
    
    CThreadController::CThreadController() : QObject()
    {
        CNC::CGUI *gui = new CNC::CGUI;
        gui->moveToThread(&guiThread);
        connect(&guiThread, &QThread::finished, gui, &QObject::deleteLater);
        //connect(this, &CThreadController::operate, gui, &CNC::CGUI::doWork);
        //connect(gui, &CNC::CGUI::resultReady, this, &CThreadController::handleResults);
        guiThread.start();
    }
    
    CThreadController::~CThreadController()
    {
        guiThread.quit();
        guiThread.wait();
    }
    
    
    /*
    Worker *worker = new Worker;
    worker->moveToThread(&workerThread);
    connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater);
    connect(this, &Controller::operate, worker, &Worker::doWork);
    connect(worker, &Worker::resultReady, this, &Controller::handleResults);
    workerThread.start();
    
    workerThread = guiThread
    *worker = *gui
    Worker = CNC::CGUI
    &Controller = &CThreadController
    */
    

    errors:
    :-1: error: moc_CThreadController.o: in function `CThreadController::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)':

    /home/michaeleric/build-GUI-Desktop-Release/moc_CThreadController.cpp:-1: error: undefined reference to `CThreadController::handleResults(QString const&)'

    :-1: error: collect2: error: ld returned 1 exit status

    i dont understand error. handleResults(QString const&) is unused on website code, nor in my code. only class name changed.
    what is the error, and how to fix it.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      micha_eleric
      wrote on last edited by
      #2
      void CThreadController::handleResults(const QString &){}
      

      was not in .cpp 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