Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. [SOLVED] QObject::QObject' : cannot access private member declared in class 'QObject' !
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved C++ Gurus
2 Posts 2 Posters 13.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    maplesyrup23
    wrote on 7 May 2012, 02:21 last edited by
    #1

    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@

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      Zlatomir
      wrote on 7 May 2012, 07:39 last edited by
      #2

      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

      https://forum.qt.io/category/41/romanian

      1 Reply Last reply
      0

      1/2

      7 May 2012, 02:21

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved