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. Model views with pagination
QtWS25 Last Chance

Model views with pagination

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
modeldelegategridpage navigation
8 Posts 4 Posters 6.2k 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.
  • M Offline
    M Offline
    Mark81
    wrote on 26 May 2016, 09:14 last edited by
    #1

    I'm looking for the best way to create a grid-based view with pagination.
    My model contains several items, and I want to display only N for each page.

    I wonder what is the best approach to do this!

    P C 2 Replies Last reply 26 May 2016, 10:18
    0
    • M Mark81
      26 May 2016, 09:14

      I'm looking for the best way to create a grid-based view with pagination.
      My model contains several items, and I want to display only N for each page.

      I wonder what is the best approach to do this!

      P Offline
      P Offline
      p3c0
      Moderators
      wrote on 26 May 2016, 10:18 last edited by p3c0
      #2

      @Mark81
      What do you mean by grid-based view ? i.e root Item will be a GridView ?
      Perhaps some more info would be useful. A pictorial representation would be better.

      May be a ListView with horizontal orientation and GridView as its delegate and resizing the delegate to fill the viewport ?

      157

      M 1 Reply Last reply 26 May 2016, 10:29
      0
      • P p3c0
        26 May 2016, 10:18

        @Mark81
        What do you mean by grid-based view ? i.e root Item will be a GridView ?
        Perhaps some more info would be useful. A pictorial representation would be better.

        May be a ListView with horizontal orientation and GridView as its delegate and resizing the delegate to fill the viewport ?

        M Offline
        M Offline
        Mark81
        wrote on 26 May 2016, 10:29 last edited by Mark81
        #3

        @p3c0 I mean the items should be placed into a grid, with fixed rows and columns.
        The classical example is the thumbnails view. One catched from Google Pictures:

        https://www.codester.com/static/uploads/items/200/preview/screenshot-1.jpg

        as you see the items are placed into a grid (2 rows, 5 columns) but you can change the page to view other items. I'm not interested into the page numbers, I'm going to use the PageIndicator QML Type.

        I think it's a very simple and common task, but I cannot find a code example. Perhaps I'm using the wrong key-words.

        P 1 Reply Last reply 26 May 2016, 10:39
        0
        • M Mark81
          26 May 2016, 10:29

          @p3c0 I mean the items should be placed into a grid, with fixed rows and columns.
          The classical example is the thumbnails view. One catched from Google Pictures:

          https://www.codester.com/static/uploads/items/200/preview/screenshot-1.jpg

          as you see the items are placed into a grid (2 rows, 5 columns) but you can change the page to view other items. I'm not interested into the page numbers, I'm going to use the PageIndicator QML Type.

          I think it's a very simple and common task, but I cannot find a code example. Perhaps I'm using the wrong key-words.

          P Offline
          P Offline
          p3c0
          Moderators
          wrote on 26 May 2016, 10:39 last edited by
          #4

          @Mark81 IMO ListView with horizontal orientation and GridView as its delegate and resizing the delegate to fill the viewport ? ListView and GridView both supports models.

          157

          1 Reply Last reply
          1
          • M Mark81
            26 May 2016, 09:14

            I'm looking for the best way to create a grid-based view with pagination.
            My model contains several items, and I want to display only N for each page.

            I wonder what is the best approach to do this!

            C Offline
            C Offline
            cheezus
            wrote on 26 May 2016, 20:19 last edited by
            #5

            @Mark81 You've got two models in play: a "page" and the actual data. So you want to create a paginated model instead. There is nothing in Qt that will make this easy for you otherwise, afaik.

            1 Reply Last reply
            1
            • M Offline
              M Offline
              Mark81
              wrote on 27 May 2016, 05:55 last edited by
              #6

              Because it seems a very common task (at least in javascript) I was hoping there is a ready-to-use QML Type. Instead I need to write some code, no problem though!

              @p3c0 I think I understand your hint. I should set my whole model to both ListView and GridView. Then I should position the view of the GridVIew (used as delegate) to show the correct "page" of my model.

              @cheezus IMO I don't need two models. I mean, the data set is the only model, while the pagination should be achieved by hand. Or I don't understand what you're saying?

              C 1 Reply Last reply 27 May 2016, 15:06
              0
              • M Mark81
                27 May 2016, 05:55

                Because it seems a very common task (at least in javascript) I was hoping there is a ready-to-use QML Type. Instead I need to write some code, no problem though!

                @p3c0 I think I understand your hint. I should set my whole model to both ListView and GridView. Then I should position the view of the GridVIew (used as delegate) to show the correct "page" of my model.

                @cheezus IMO I don't need two models. I mean, the data set is the only model, while the pagination should be achieved by hand. Or I don't understand what you're saying?

                C Offline
                C Offline
                cheezus
                wrote on 27 May 2016, 15:06 last edited by
                #7

                @Mark81 Even in JavaScript you have two models, you just don't typically think of it that way: model 1: the database, model 2: the results on the client side.

                Here, you have two models: 1 - the database, 2 - the QML side.

                So what you need to do is create a paginated model using LIMIT/OFFSET queries.

                1 Reply Last reply
                1
                • N Offline
                  N Offline
                  Narjisinfotech
                  Banned
                  wrote on 17 Jul 2019, 06:20 last edited by
                  #8
                  This post is deleted!
                  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