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. How to limit and repeat the items in a QML List View
Forum Updated to NodeBB v4.3 + New Features

How to limit and repeat the items in a QML List View

Scheduled Pinned Locked Moved QML and Qt Quick
8 Posts 6 Posters 7.9k 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.
  • M Offline
    M Offline
    maxpayne
    wrote on last edited by
    #1

    Hi,

    I have a model which basically contains some integers (say 1 to 10). I want my list view to show only 3 items ( one highlighted, one above and one below). How do i achieve this? Next, imagine that the view is flicked and the last item is visible..on further flicking i want the first item to become visible again...i.e the data in the model is repeated from the beginning.

    I am not sure how to achieve this and any hints will be appreciated.

    thanks,
    max

    1 Reply Last reply
    0
    • W Offline
      W Offline
      wladek
      wrote on last edited by
      #2

      Hi max,

      To limit your view to show just 3 items, you can try to use a delegate Item which takes 1/3 from the ListView's height.
      For the other stuff I don't have an idea at this point, but it is something I would also like to know :)

      Regards,
      Wladek

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mario
        wrote on last edited by
        #3

        You should take a look at PathView instead. I think the PathView wraps when "flicking" and I also think that you can specify the number of visible items with 'pathItemCount'.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          maxpayne
          wrote on last edited by
          #4

          i will try PathView but i would nonetheless appreciate an answer that uses a ListView.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mbrasser
            wrote on last edited by
            #5

            Hi,

            ListView in Qt Quick 1 doesn't have built-in support for "infinite"/wrapping lists, so as mario indicated the standard advice in this situation is to try PathView.

            Another approach might be to try manipulating the model -- maybe it would work to add items to the end of the model (and remove some from the beginning) when you got near the end of the list? I'd be very interested to hear if you (or others) were able to get something working with ListView.

            Regards,
            Michael

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #6

              It is also unfortunate that the API's for the model-view stuff in QML are private. Otherwise, you would be able to write your own view that implements this. I hope that Quick 2 will change that too.

              1 Reply Last reply
              0
              • M Offline
                M Offline
                maxpayne
                wrote on last edited by
                #7

                using path view + path line did the trick for me..but as andre pointed out, it will be nice if we could reimplement statndard views.
                @mbrasser : i will try manipulating the model and see if it works..

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  Ayelis
                  wrote on last edited by
                  #8

                  If anyone has ever figured out how to make a QML PathView repeat the items in the list when the visible items are greater than the list count, that information would be appreciated. Thanks.
                  #bump

                  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