Results 1 to 3 of 3

Thread: QSharedPointer forward declare, compile warnings persist.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    207
    Thanks
    20
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QSharedPointer forward declare, compile warnings persist.

    QSharedPointer gives nasty compile time warnings if the class whose smart pointer is being made is forward declared. QScopedPointer documentation has some documentation on how to avoid warnings with forward declaration. As has been pointed out in this bug, works for QSharedPointer too...
    https://bugreports.qt-project.org/browse/QTBUG-7302

    However compiler warnings persist for me... consider code...
    Qt Code:
    1. class MyPrivateClass; // forward declare MyPrivateClass
    2.  
    3. class MyClass
    4. {
    5. private:
    6. QList<QScopedPointer<MyPrivateClass> > privatePtr; //QList QScopedPointer to forward declared class
    7.  
    8. public:
    9. MyClass(); // OK
    10. ~MyClass(); // Not a VIOLATION - Destructor must not be inline
    11.  
    12. private:
    13. Q_DISABLE_COPY(MyClass) // OK - copy constructor and assignment operators
    14. // are now disabled, so the compiler won't implicitely
    15. // generate them.
    16. };
    To copy to clipboard, switch view to plain text mode 
    Any way to avoid the warnings.. the qt version is 4.8.4... the bug is apparently fixed in 5.0 but can't shift.

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSharedPointer forward declare, compile warnings persist.

    great, thanks.

    Do you have a question?
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QSharedPointer forward declare, compile warnings persist.

    You cannot put QScopedPointers into a QList because to do so requires the ability to copy the QScopedPointer, which is is expressly disabled by a private copy constructor. This generates nasty errors, not warnings.

    If you were using QSharedPointer then the issue goes away.

Similar Threads

  1. Replies: 11
    Last Post: 20th November 2012, 22:18
  2. QSharedPointer / QWeakPointer in QML?
    By centipede in forum Qt Quick
    Replies: 1
    Last Post: 23rd May 2012, 09:25
  3. Replies: 1
    Last Post: 12th December 2010, 16:45
  4. emitting QSharedPointer
    By babu198649 in forum Newbie
    Replies: 11
    Last Post: 26th July 2010, 08:51
  5. QMdiSubWindow - Warnings while compile
    By estanisgeyer in forum Qt Programming
    Replies: 2
    Last Post: 3rd February 2009, 15:37

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.