Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Grouping ListView elements
Forum Updated to NodeBB v4.3 + New Features

Grouping ListView elements

Scheduled Pinned Locked Moved QML and Qt Quick
11 Posts 2 Posters 3.0k 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.
  • J Offline
    J Offline
    Julie1986
    wrote on 4 Sept 2012, 09:22 last edited by
    #1

    I have a listview with group id 1 and 0. I need to group 0's and 1's separately. Any idea how to do it? Do I need to create another ListModel and add these elements accordingly or can i re-arrange my current ListView.

    Thanks in advance

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on 4 Sept 2012, 09:52 last edited by
      #2

      What do you mean with 'group' exactly? Do you need to just sort them so they stay together, or do you really need to visually group them?

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Julie1986
        wrote on 4 Sept 2012, 10:08 last edited by
        #3

        I need to sort them in one order, parameter with id 0 at first and then parameter with id 1. Thanks

        1 Reply Last reply
        0
        • J Offline
          J Offline
          Julie1986
          wrote on 4 Sept 2012, 10:13 last edited by
          #4

          am unable to get the logic to solve it with index. for ex. i have 6 elements with id 0 1 2 2 1 0 in the following manner i need to display it as 0 0 1 1 2 2. I hope now it is clear

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on 4 Sept 2012, 10:14 last edited by
            #5

            Sure, that is very possible. Use a [[doc:QSortFilterProxyModel]] between your model and your view, and sort on the appropriate role and column. If you need to sort within the groups too, you will have to resort to subclassing and reimplementing the virtual bool lessThan ( const QModelIndex & left, const QModelIndex & right ) const function.

            1 Reply Last reply
            0
            • J Offline
              J Offline
              Julie1986
              wrote on 4 Sept 2012, 10:20 last edited by
              #6

              Am working completely in qml so am not used to these functions.. do u have an example

              1 Reply Last reply
              0
              • J Offline
                J Offline
                Julie1986
                wrote on 4 Sept 2012, 10:21 last edited by
                #7

                Its toooo complicated for me as a beginner.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  andre
                  wrote on 4 Sept 2012, 10:22 last edited by
                  #8

                  In that case, you should have posted in the appropriate forum. Now, you give no clue whatsoever as to the technology you are using. I will move this topic there.

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    andre
                    wrote on 4 Sept 2012, 10:23 last edited by
                    #9

                    [quote author="Julie1986" date="1346754100"]Its toooo complicated for me as a beginner.[/quote]

                    Please don't followup post so rapidly. Just edit your previous post instead.

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      andre
                      wrote on 4 Sept 2012, 10:25 last edited by
                      #10

                      [quote author="Julie1986" date="1346754049"]Am working completely in qml so am not used to these functions.. do u have an example[/quote]

                      For QML, did you take a look at setting the section.property for the ListView?

                      1 Reply Last reply
                      0
                      • J Offline
                        J Offline
                        Julie1986
                        wrote on 4 Sept 2012, 10:37 last edited by
                        #11

                        ya I tried to use that but it does not work according to my rule:(

                        1 Reply Last reply
                        0

                        1/11

                        4 Sept 2012, 09:22

                        • Login

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