Results 1 to 2 of 2

Thread: Iteration problem

  1. #1
    Join Date
    Sep 2007
    Posts
    22
    Thanks
    1

    Default Iteration problem

    Hi
    I have a Qlistview which has items in it. Each item has its children like:
    a
    b
    c
    d
    d1
    d2
    e

    d has for example two children. My problem is that when i want to select the item d
    that its children should also be selected. Here comes my code:

    Qt Code:
    1. QListViewItemIterator it(mylistview, QListViewItemIterator::Selected);
    2. while( it.current())
    3. {
    4. MyClass * p1 = ((MyListViewItem*)it.current())->getP1();
    5. MyClass * p2 = ((MyListViewItem*)it.current())->getP2();
    6. if ( p1 )
    7. {
    8. // code
    9. }
    10. if ( p2 )
    11. // code
    12.  
    13. it++;
    14. }
    To copy to clipboard, switch view to plain text mode 

    Can someone please direct me how to select the children of the items in above situation?
    Regards,

  2. #2
    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: Iteration problem

    You should do it by using a recursive method, especially that children might have children as well...

Similar Threads

  1. Graphics view display problem.
    By kiranraj in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2007, 07:08
  2. [QMYSQL] connection problem
    By chaos_theory in forum Installation and Deployment
    Replies: 5
    Last Post: 2nd July 2007, 09:52
  3. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  4. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14:08
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.