Results 1 to 7 of 7

Thread: Q_declare_private()

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2008
    Posts
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Q_declare_private()

    I'm just looking at some example QT code, and I notice that someties in the header file there will be something like so:

    Qt Code:
    1. class MyClassPrivate;
    2.  
    3. class MyClass : public QObject
    4. {
    5. public:
    6. MyClass( QObject *parent = 0 );
    7. ...other non relevant stuff...
    8. protected:
    9. MyClassPrivate *const ptr;
    10. MyClass( MyClassPrivate &the_ptr, QObject *parent = 0 );
    11. private:
    12. Q_DECLARE_PRIVATE( MyClass );
    13. };
    To copy to clipboard, switch view to plain text mode 

    I'm just curious what does this "macro" do? Does it offer the ability to have a private version of the class? Why do they want a separate Protected Constructor? Can somebody give me an example why it is useful?

    Thanks,

    Michael
    Last edited by marf; 19th July 2008 at 18:22. Reason: updated with constructors

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.