Hey,
I'm trying to compile a simple producer-consumer program with Qt, using QThreads. I get this error message when trying to compile:
In file included from /usr/include/qt4/QtCore/QThread:1,
from producer.h:4,
from mainwindow.cpp:3:
/usr/include/qt4/QtCore/qobject.h: In copy constructor ‘QThread::QThread(const QThread&)’:
/usr/include/qt4/QtCore/qobject.h:309: error: ‘QObject::QObject(const QObject&)’ is private
/usr/include/qt4/QtCore/qthread.h:60: error: within this context
In file included from mainwindow.cpp:3:
producer.h: In copy constructor ‘Producer::Producer(const Producer&)’:
producer.h:7: note: synthesized method ‘QThread::QThread(const QThread&)’ first required here
mainwindow.cpp: In member function ‘void MainWindow::on_btnStart_clicked()’:
mainwindow.cpp:31: note: synthesized method ‘Producer::Producer(const Producer&)’ first required here
make: *** [mainwindow.o] Virhe 1
I've tried to google this, but so far I haven't found anything related to this.
Here's my producer.h and producer.cpp:
#ifndef PRODUCER_H
#define PRODUCER_H
#include <QThread>
#include <QStack>
class Producer : public QThread {
Q_OBJECT
public:
Producer(QStack<int> &s_par, int n_par);
void run();
private:
int count;
QStack<int> prod_stack;
};
#endif // PRODUCER_H
#include "producer.h"
Producer::Producer(QStack<int> &s_par, int n_par) : QThread() {
count = n_par;
prod_stack = s_par;
}
void Producer::run() {
for(int i = 1; i <= count; i++) {
prod_stack.push(i);
}
}