Results 1 to 2 of 2

Thread: inserting to Qlist of QSharedPointer

  1. #1
    Join Date
    Jul 2010
    Posts
    63
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default inserting to Qlist of QSharedPointer

    say i have a reference to an object of the appropriate class i want to insert to my QList of such QSharedPointers - can i use
    Qt Code:
    1. the_list << the_ref
    To copy to clipboard, switch view to plain text mode 
    or should it be
    Qt Code:
    1. the_list << QSharedPointer<TheClass>(the_ref)
    To copy to clipboard, switch view to plain text mode 

    ?

  2. #2
    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: inserting to Qlist of QSharedPointer

    What does your compiler say? It knows what works (is safe) and what does not.

    If the_ref is a pointer to TheClass then your first attempt matches no operator<< variant, and the second does.
    If the the_ref is a reference to an actual instance then neither is correct.

Similar Threads

  1. Replies: 4
    Last Post: 20th August 2010, 13:54
  2. emitting QSharedPointer
    By babu198649 in forum Newbie
    Replies: 11
    Last Post: 26th July 2010, 08:51
  3. QSharedPointer of type void
    By HERC in forum Qt Programming
    Replies: 0
    Last Post: 12th May 2010, 12:59
  4. Problem with QSharedPointer
    By weaver4 in forum Newbie
    Replies: 2
    Last Post: 19th April 2010, 14:22
  5. QSharedPointer - how to prevent delete?
    By Piskvorkar in forum Qt Programming
    Replies: 7
    Last Post: 31st March 2010, 15:46

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.