Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Sort array

Sort array

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 4.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ranger0
    wrote on 4 Mar 2013, 21:01 last edited by
    #1

    Hi folks,

    Any idea of what to do to sort an array writen like this:

    @
    QList< QList<QVariant> >
    @

    I want to choose a column to sort and the other QLists must have it´s order modified according with that one.

    Thanks

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      qxoz
      wrote on 6 Mar 2013, 12:44 last edited by
      #2

      Well there are several ways to do that:

      1. Create your own function based on some "sorting algotythms":http://en.wikipedia.org/wiki/Sorting_algorithm;
      2. Create some sheild class for using with qSort;
      3. If you need display result data in some view you can create some custom model which contains your data and bind it with "QSortFilterProxyModel":http://qt-project.org/doc/qt-4.8/qsortfilterproxymodel.html
      1 Reply Last reply
      0
      • R Offline
        R Offline
        ranger0
        wrote on 6 Mar 2013, 13:45 last edited by
        #3

        [quote author="qxoz" date="1362573895"]Well there are several ways to do that:

        1. Create your own function based on some "sorting algotythms":http://en.wikipedia.org/wiki/Sorting_algorithm;
        2. Create some sheild class for using with qSort;
          [/quote]

        Hi qxoz. Thanks for your help!

        I'm wondering if you could help me to realize how to link all columns.

        I know I could use qSort to sort one QList, but how could I link that to the other ones?

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          qxoz
          wrote on 6 Mar 2013, 18:37 last edited by
          #4

          May be this can help:
          "stackoverflow.com":http://stackoverflow.com/questions/5103682/how-to-sort-qlistmyclass-using-qt-library-maybe-qsort
          but i didn't try that.

          1 Reply Last reply
          0

          1/4

          4 Mar 2013, 21:01

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved