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
Qt 6.11 is out! See what's new in the release blog

Sort array

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 4.7k Views 1 Watching
  • 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 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 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 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 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

          • Login

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