简体   繁体   中英

C++ Thread::process() function

I am trying to run a separate thread to do some downloading while my GUI runs with Qt5 in c++. I have everything worked out so far, except when I try to compile the code, this error:

moc_threader.cpp:82: error: undefined reference to `WorkerThread::process()'

I get this even though WorkerThread::process() is neither defined nor called anywhere in my scripts. My thread class is as follows:

class WorkerThread : public QThread {
    Q_OBJECT
    void run() override{
            try {
            //download
            } catch (const std::exception& e) {
            //present error
            }
             emit progressChanged("Info");
        }
    public slots:
        void process();
    // Define signal:
signals:
    void progressChanged(QString info);
};

And I'm calling it like this:

WorkerThread *workerThread = new WorkerThread;
connect(workerThread, SIGNAL(progressChanged(QString)),SLOT(onProgressChanged(QString)));
connect(workerThread, SIGNAL(finished()),workerThread, SLOT(deleteLater()));
workerThread->start(); 

Is it something I'm doing wrong in calling it or something I did wrong in writing it or what?

Well, it looks like the WorkerThread::process() slot was not being used effectively anywhere, and it does look like the process method was previously defined somewhere else. Commenting out the line and editing the code to suit did the job. Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM