Results 1 to 2 of 2

Thread: childred of a tree item held with QSharedPointer ?

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

    Default childred of a tree item held with QSharedPointer ?

    i have a tree model, and all sorts of tree items. i want to be able to recover deleted items (say using undo command) from the tree by holding them outside of the model after they have been removed from it.

    generally and Qt specifically speaking, will using a shared pointers for child items be a bad call?

    on a different note, which is a better container for QSharedPointer - a QList or a QVector?

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: childred of a tree item held with QSharedPointer ?

    A pointer to the item is not enough IMHO.
    You also need its location in the hierarchy.
    And you will have to supply some logic for example in a case you want to restore a certain item, which one or more parents items are also removed, or if its original location in the model has changed to to removing/adding items above it.
    That is just from the top of my head, there are probably other problems as well.
    I would tend to use another model, as a "mirror", in which I would hold the removed items, and probably also mirror operations on it so that the general structure of both models will stay consistant this way you have all the information of the items still.
    However, this approach too, needs a very well thought through algorithm.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Highlight Tree Item Viw
    By sajis997 in forum Qt Programming
    Replies: 4
    Last Post: 19th July 2011, 09:40
  2. Tree Model Item Highlighter
    By sajis997 in forum Qt Programming
    Replies: 9
    Last Post: 9th January 2011, 17:58
  3. Qt needs a sub item tree iterator
    By mrknight in forum Qt Programming
    Replies: 1
    Last Post: 3rd November 2010, 03:18
  4. Replies: 14
    Last Post: 9th November 2006, 08:35
  5. Replies: 1
    Last Post: 21st March 2006, 12:54

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.