[SOLVED] QObject::QObject' : cannot access private member declared in class 'QObject' !



  • 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@



  • 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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.