Results 1 to 7 of 7

Thread: QObject explicit constructing and QSharedData

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2010
    Location
    Poland
    Posts
    112
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo
    Thanks
    8
    Thanked 3 Times in 3 Posts

    Default Re: QObject explicit constructing and QSharedData

    Qt Code:
    1. class QubiconModelData;
    2. class QubiconModel : public QObject {
    3. public:
    4. QubiconModel();
    5. QubiconModel(const QubiconModel &);
    6. QubiconModel &operator=(const QubiconModel &);
    7. ~QubiconModel();
    8.  
    9. private:
    10. QExplicitlySharedDataPointer<QubiconModelData> data;
    11. };
    To copy to clipboard, switch view to plain text mode 

    here is the header...I didn't wrote it myself, this particular part of code has been auto-generated via QtCreator new class wizard.
    My schedule makes my cry
    My works makes my laugh
    My life makes... oh...no....

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QObject explicit constructing and QSharedData

    It won't work. QObject instances can't be copied. Why do you want to derive that class from QObject?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Sep 2010
    Location
    Poland
    Posts
    112
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo
    Thanks
    8
    Thanked 3 Times in 3 Posts

    Default Re: QObject explicit constructing and QSharedData

    Wanted to have out-of-the-box support for automatic objects deallocation...however it seems that since it is not possible I will just take care of it myself
    My schedule makes my cry
    My works makes my laugh
    My life makes... oh...no....

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QObject explicit constructing and QSharedData

    Quote Originally Posted by kornicameister View Post
    Wanted to have out-of-the-box support for automatic objects deallocation..
    I don't see how that's related. If you have a value-based class that contains a shared data pointer then you allocate such objects on the stack and you don't need any special automatic object deallocation because deallocation is automatic by the definition. If you allocate such objects on the heap, then you usually don't need them to be based around shared data and even if you do, you can use an external smart pointer to manage such object.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    kornicameister (12th March 2013)

  6. #5
    Join Date
    Sep 2010
    Location
    Poland
    Posts
    112
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo
    Thanks
    8
    Thanked 3 Times in 3 Posts

    Default Re: QObject explicit constructing and QSharedData

    That's some useful explanation...thank you
    My schedule makes my cry
    My works makes my laugh
    My life makes... oh...no....

Similar Threads

  1. How to use explicit labels/ticks?
    By ssample in forum Qwt
    Replies: 3
    Last Post: 18th January 2013, 12:16
  2. QsharedMemory or QsharedData ?
    By OverTheOCean in forum Qt Programming
    Replies: 2
    Last Post: 7th November 2010, 23:33
  3. Implicit vs. explicit
    By lni in forum Qt Programming
    Replies: 4
    Last Post: 22nd September 2009, 03:26
  4. Constructing QImage from QBytearray
    By dbrmik in forum Newbie
    Replies: 6
    Last Post: 16th December 2008, 16:00
  5. QSharedData - implicit sharing
    By gyre in forum Newbie
    Replies: 4
    Last Post: 28th October 2007, 20:09

Tags for this Thread

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.