Results 1 to 4 of 4

Thread: How to iterate QMap twice

  1. #1
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Thanks
    30
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question How to iterate QMap twice

    Hi to all, I have iterated a QMap, but after this, I have to iterate it again, the problem is, I do not know after the first iteration, the iterator is at end of the QMap, or it locaetes itself at the first again automatically??

    Thanks in advance!

  2. #2
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to iterate QMap twice

    Hi,

    Simply call "begin()" and get the new iterator that points to the start of the map.
    Òscar Llarch i Galán

  3. #3
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Thanks
    30
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to iterate QMap twice

    thanks, but something wrong it seems.
    Qt Code:
    1. QMapIterator<int, QMap<QString, QToolButton*>* > tabIter(tabs);
    To copy to clipboard, switch view to plain text mode 
    and after the first iteration :
    Qt Code:
    1. tabIter = tabs.begin();
    To copy to clipboard, switch view to plain text mode 

    But the compiler find some error

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to iterate QMap twice

    use this method QMapIterator::toFront if you use java-style iterators.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

Similar Threads

  1. QMap as function argument...
    By cydside in forum Qt Programming
    Replies: 5
    Last Post: 18th April 2009, 17:59
  2. How to implement operator<() for QMap
    By learning_qt in forum Qt Programming
    Replies: 6
    Last Post: 9th January 2009, 10:21
  3. QMap model data
    By gyre in forum Newbie
    Replies: 3
    Last Post: 9th December 2007, 22:19
  4. QMap Problem with arguments.
    By ankurjain in forum Qt Programming
    Replies: 1
    Last Post: 24th May 2006, 12:12
  5. QMap destructor bug
    By Ruud in forum Qt Programming
    Replies: 6
    Last Post: 8th April 2006, 09:08

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.