Results 1 to 7 of 7

Thread: [SOLVED] qSort() and iterator const-ness(?)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Jun 2006
    Posts
    81
    Thanks
    6
    Thanked 5 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: qSort() and iterator const-ness(?)

    Hi Lykurg,

    Quote Originally Posted by Lykurg View Post
    I think that actions() returns a temporary list which you sort, but when you call actions() again, the sort will be gone. So try to use
    Qt Code:
    1. QList<QAction *> tmpList = actionGroup_.actions();
    2. qSort(tmpList.begin(), tmpList.end(), sortOrder);
    3. toolBar_.clear();
    4. toolBar_.addActions(tmpList);
    To copy to clipboard, switch view to plain text mode 
    Perfectly right!
    Edit: Well, I don't sort this way, but this explains why begin() and end() are in wrong order or rather totally unrelated.

    Thx alot!

    PS: How could i have found out? The QActionGroup doc doesn't say anything about temp'ness.
    Last edited by zaphod.b; 28th July 2010 at 16:11.

Similar Threads

  1. QSort
    By skumar7777 in forum Qt Programming
    Replies: 4
    Last Post: 2nd December 2008, 06:18
  2. qSort with lessThan
    By soul_rebel in forum Qt Programming
    Replies: 4
    Last Post: 19th August 2008, 18:14
  3. const member and const method
    By mickey in forum General Programming
    Replies: 8
    Last Post: 9th April 2008, 09:44
  4. qSort() problem
    By darksaga in forum Qt Programming
    Replies: 5
    Last Post: 17th August 2007, 11:47
  5. [Qt4] QSORT
    By jane in forum Qt Programming
    Replies: 6
    Last Post: 24th May 2006, 23:38

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.