saman_artorious
13th June 2012, 13:14
I would thank if you tell me how to inherit two classes in qt.
I have several objects, each of which may connect to serial port via producer and consumer.
So, for emission n reception I need to connect the serial object inside producer and consumer classes to the other object outside.
Now, my producer n consumer class look like this:
extern const int DataSize;
extern const int BufferSize;
extern char buffer[100];
extern QWaitCondition bufferNotEmpty;
extern QWaitCondition bufferNotFull;
extern QMutex mutex;
extern int numUsedBytes;
class Producer : public QThread
{
public:
Producer();
void run();
private:
rs485 *rs_485;
};
I tried adding QObject as well, but it prompted errrors.
i did this
#ifndef PRODUCER_H
#define PRODUCER_H
#include <QWaitCondition>
#include <QThread>
#include <QMutex>
#include <QTime>
#include <QSemaphore>
#include "rs485.h"
extern const int DataSize;
extern const int BufferSize;
extern char buffer[100];
extern QWaitCondition bufferNotEmpty;
extern QWaitCondition bufferNotFull;
extern QMutex mutex;
extern int numUsedBytes;
class Producer : public QObject, public QThread
{
Q_OBJECT
public:
explicit Producer(QObject *parent = 0);
void run();
public slots:
void ProducerWritePacket(QByteArray);
private:
rs485 *rs_485;
};
#endif // PRODUCER_H
and here's the error:
‘QObject’ is an ambiguous base of ‘Producer’
I have several objects, each of which may connect to serial port via producer and consumer.
So, for emission n reception I need to connect the serial object inside producer and consumer classes to the other object outside.
Now, my producer n consumer class look like this:
extern const int DataSize;
extern const int BufferSize;
extern char buffer[100];
extern QWaitCondition bufferNotEmpty;
extern QWaitCondition bufferNotFull;
extern QMutex mutex;
extern int numUsedBytes;
class Producer : public QThread
{
public:
Producer();
void run();
private:
rs485 *rs_485;
};
I tried adding QObject as well, but it prompted errrors.
i did this
#ifndef PRODUCER_H
#define PRODUCER_H
#include <QWaitCondition>
#include <QThread>
#include <QMutex>
#include <QTime>
#include <QSemaphore>
#include "rs485.h"
extern const int DataSize;
extern const int BufferSize;
extern char buffer[100];
extern QWaitCondition bufferNotEmpty;
extern QWaitCondition bufferNotFull;
extern QMutex mutex;
extern int numUsedBytes;
class Producer : public QObject, public QThread
{
Q_OBJECT
public:
explicit Producer(QObject *parent = 0);
void run();
public slots:
void ProducerWritePacket(QByteArray);
private:
rs485 *rs_485;
};
#endif // PRODUCER_H
and here's the error:
‘QObject’ is an ambiguous base of ‘Producer’