[SOLVED] QObject::QObject' : cannot access private member declared in class 'QObject' !
-
wrote on 7 May 2012, 02:21 last edited by
Some of the functions in this class I defined uses some Qt children methods, so I had to have the Q_OBJECT macro. However, this is the sole error that comes up when I attempt to compile, and I neither know how to interpret it nor to fix it. Any input?
@ #ifndef HARDTRIGGER_H
#define HARDTRIGGER_H#include <PvApi.h>
#include <QObject>class tCamera : public QObject
{
Q_OBJECT
public:
unsigned long UID;
tPvHandle Handle;
tPvFrame Frame;
tPvUint32 Counter;
char Filename[20];
bool Abort;
private slots:
void WaitForCamera();
bool CameraGet();
bool CameraSetup();
void CameraUnsetup();
bool CameraStart();
void CameraStop();
bool CameraSnap();
};
#endif // HARDTRIGGER_H@ -
wrote on 7 May 2012, 07:39 last edited by
That must happen because the default constructor of QObject is private, so define an constructor for your class to pass a QObject* parent to the QObject constructor
@
class tCamera : public QObject
{
Q_OBJECT
public:
tCamera(QObject* parent = 0); //pass parent to QObject's c-tor in the definition of your c-tor
//...
@
Also you should make sure to disable the copy for your class using "q_disable_copy or private copy c-tor and assignment operator":http://qt-project.org/doc/qt-4.8/qobject.html#Q_DISABLE_COPY
1/2