Results 1 to 4 of 4

Thread: Garbabe Collection

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2007
    Posts
    78
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Garbabe Collection

    Not sure how to proceed and before getting in too deep I have a few questions. I will start with a small code example.

    Qt Code:
    1. typedef struct mystructure {
    2. int x;
    3.  
    4. QList<mystructure> children;
    5. } mystructure;
    6.  
    7. QList<mystructure> mystructureList; // List of parent QTreeWidgetItem(s) only need these items as children references will be contained in mystructure
    8. QHash<QTreeWidgetItem *,mystructure> mystructureFromItem; // lookup hash using QTreeWidgetItem index for mystructure
    To copy to clipboard, switch view to plain text mode 

    My problem arises since I am not using pointers if I have already appended a mystructure to the QList and add more children after that fact they will not be stored.

    If I Q_DECLARE_METATYPE(mystructure) I would have to implement == functionality for QList in order to use indexOf() features to just replace the entry with the updated data.

    Should I just use a standard pointer linked list instead of forcing this into Qt mechanics? Or is there just something else I am missing?

    Bob

    EDIT: Forgot to add the question of making QList<mystructure> *mystructureList, and QList<mystructure> *children. In this case would I need to do my own memory release or would Qt's garbage collection take care of it?
    Last edited by coderbob; 19th November 2007 at 20:56.

Similar Threads

  1. Resource Collection File maximux size
    By Lele in forum Qt Programming
    Replies: 1
    Last Post: 9th August 2006, 10:41
  2. lib using Image Collection
    By bitChanger in forum Qt Programming
    Replies: 4
    Last Post: 25th July 2006, 17:30

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.