Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6597593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:13:44+00:00 2026-05-25T18:13:44+00:00

OR other way to formulate my question (though it didn’t solve my problem): 'QObject::QObject'

  • 0

OR other way to formulate my question (though it didn’t solve my problem): 'QObject::QObject' cannot access private member declared in class 'QObject'

I need SIGNALs and SLOTS functionality in my class, but I assume it is not possible without to derive from QObject?

class MyClass
{
signals:
   importantSignal();
public slots:
   importantSlot();
};

The Problem seems to be that I need to derive from QObject to use signals and slots … but I need the default contructor of MyClass. But I can’t construct them because of the following feature of QObject:
No Copy Constructor or Assignment Operator.

I tried a lot …

So my shoul Class look like that:

#include <QObject>
class MyClass: public QObject
{
    Q_OBJECT
public:
    explicit MyClass(QObject *parent = 0); //autogenerated by qtcreator for QObject derived class
    MyClass(const MyClass * other);

signals:
    importantSignal();
public slots:
    importantSlot();
};

I need the default contructor of MyClass.

So is there any possibility do avoid the “‘QObject::QObject’ cannot access private member declared in class ‘QObject'” error?

Or as an alternative is there any possibility to use signals and slots without QObject?

I’m glad for any advice.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:13:45+00:00Added an answer on May 25, 2026 at 6:13 pm

    If you want a copyable object with QObject features you need membership (by pointer) rather than inheritence.

    You can derive a class Handler from QObject where Handler‘s slots call SomeInterface virtual functions on its parent.

    struct NonQObjectHandler {
        virtual ~ NonQObjectHandler () {}
        virtual void receive (int, float) = 0;
    };
    
    class Handler : public NonQObjectHandler {
        struct Receiver;
        std :: unique_ptr <Receiver> m_receiver;
        void receive (int, float); // NonQObjectHandler
    public:
        Handler ();
        Handler (const Handler &); // This is what you're really after
    };
    
    class Handler :: Receiver : public QObject {
    Q_OBJECT
    private:
        NonQObjectHandler * m_handler;
    private slots:
        void receive (int, float); // Calls m_handler's receive
    public:
        Receiver (NonQObjectHandler *);
    };
    
    Handler :: Handler ()
    : m_receiver (new Receiver (this))
    {
    }
    
    Handler :: Handler (const Handler & old)
    : m_receiver (new Receiver (this))
    {
        // Copy over any extra state variables also, but
        // Receiver is created anew.
    }
    
    Handler :: Receiver :: Receiver (NonQObjectHandler * h)
    : m_handler (h)
    {
        connect (foo, SIGNAL (bar (int, float)), this, SLOT (receive (int, float)));
    }
    
    void Handler :: Receiver :: receive (int i, float f)
    {
        m_handler -> receive (i, f);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Similar to this question only the other way of flow. Insert Picture into SQL
Not sure of the best way to ask this question other than: I'm writing
I've done the other way around (calling pure C++ code from .NET) with C++/CLI,
or the other way around? I use generic lists all the time. But I
Is there any other way in java to implement call backs apart from inner
Is there any other way to change the QTextLayout of a QTextBlock that is
Is there any other way to write javascript:false that is more pleasant? I'm building
Or is it now the other way around? From what I've heard there are
Is there a free API or some other way to determine what carrier a
Is there a way to use the HAVING clause in some other way without

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.