Results 1 to 7 of 7

Thread: QObject explicit constructing and QSharedData

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

    Default QObject explicit constructing and QSharedData

    Hi,
    I want to create the class which extends QObject and support QSharedData. However I am given with the compiler warning as
    follow:
    Qt Code:
    1. ostrzeżenie:base class 'class QObject' should be explicitly initialized in the copy constructor [-Wextra]
    To copy to clipboard, switch view to plain text mode 
    .

    Therefore I am thinking of this approach being valid or invalid, because my intention is to have the class which can be initialized with parent from any other class but with QSharedData support. How can I get this without causing compiler to complain ?
    My schedule makes my cry
    My works makes my laugh
    My life makes... oh...no....

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QObject explicit constructing and QSharedData

    It would help to see the class header and source.

    Cheers,
    _

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

    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....

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    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.


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

    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....

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    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.


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

    kornicameister (12th March 2013)

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

    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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.