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. [Solved] Unable to get PathLine/PathView to display sufficient items
QtWS25 Last Chance

[Solved] Unable to get PathLine/PathView to display sufficient items

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 2 Posters 5.9k 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.
  • S Offline
    S Offline
    scifi.guy
    wrote on last edited by
    #1

    Hi,

    I am trying to customise the page control example published on "forum nokia wiki":http://wiki.forum.nokia.com/index.php/How_to_create_a_Page_Control_component_in_QML. The article describes how to use PathView/PathLine to create pagination effect.

    I am trying to customize this example to something like the screenshot below.

    !http://i53.tinypic.com/j0emn6.jpg(Screenshot)!

    I have six ListModel items (rectangles) in total. I want to iterate through them. At any point of time I want to display 4 items (rectangles) on screen. The problem I have is I can only see 3 items at a time.

    I am pretty sure this is a logic issue, but I could not understand PathView/PathLine concept enough to make it work. Could anyone take a look at my code and tell me where is the missing link.

    Here is the key part of the code.
    @
    path: Path {
    startX: pageControl.width / 2
    startY: 100 * (1 - listModel.count) / 2 //100 is the height of each rectangle
    PathLine {
    x: pageControl.width / 2
    y: 100 * (1 + listModel.count) /2 //100 is the height of each rectangle
    }
    }
    @

    Here is the "full code":http://pastebin.com/rsEtjsRb

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

      Hi,

      The first item is vertically centered on the start point of the path, and in this case that is -250. That ends up putting 3 items off screen, and 3 items on. Have you tried defining a path that is only on screen (e.g. with startY at 50), and using pathItemCount to limit the number of items shown on the path?

      Regards,
      Michael

      1 Reply Last reply
      0
      • S Offline
        S Offline
        scifi.guy
        wrote on last edited by
        #3

        Thanks Michael - I tried startX as -150.

        !http://i53.tinypic.com/fuuxzd.png(Screenshot)!

        I can now see 4 items but the list is starting at 6th item. So close.

        Maybe I am unnecessarily complicating things. I have an XmlListModel and the number of items in the model changes dynamically. I have enough space to display 4 items on screen using a ListView/PageView. I would like to have some sort of paging control for the view so that user can click a button or use a key to go to next page. Dragging/kinetic-scrolling is not an option since this will be used in a maemo home screen widget and the touch controls do not work on home screen. This is the closest I got using a PageView. The ListView just extends beyond the screen which is not what I was looking for.

        Is there any other way to implement paging?

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

          Hi,

          The reason 6 shows up first has to do with preferredHighlightBegin and preferredHighlightEnd. If you set them to something like 2/5 or 2/6 instead you should get the desired result.

          I'd still suggest trying a shorter, on-screen only path along with pathItemCount as a preferred approach, however.

          Regards,
          Michael

          1 Reply Last reply
          0
          • S Offline
            S Offline
            scifi.guy
            wrote on last edited by
            #5

            Finally, preferredHighlightBegin and preferredHighlightEnd did the trick.

            I tried tweaking pathItemCount but assigning it added too much space between items and more items are pushed off screen. In some cases items were overlapping each other. The best scenario was pathItemCount = listMode.count which gives the same result as leaving pathItemCount unassigned. So I decided to leave it unassigned.

            This is my modified PathView that is working.

            @
            PathView {
            id: myPathView

            width: parent.width
            anchors.top: parent.top
            anchors.bottom: pageIndicator.top

                Keys.onDownPressed: if (!moving && interactive) incrementCurrentIndex()
                Keys.onUpPressed: if (!moving && interactive) decrementCurrentIndex()
            

            flickDeceleration: 500
            preferredHighlightBegin: 1/listModel.count
            preferredHighlightEnd: 1/listModel.count
            //pathItemCount: listModel.count
            focus: true
            interactive: true
            model: listModel
            delegate: appDelegate
            path: Path {
            startX: pageControl.width / 2
            startY: -itemHeight/2
            PathLine {
            x: pageControl.width / 2
            y: listModel.count * 100 - itemHeight/2
            }
            }
            }
            @

            Thanks a lot Michael!

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

              Glad you got something working :-)

              (and you are right, having the path only on-screen does make odd effects when the items are added/removed at the ends of the path, which I didn't think about)

              Regards,
              Michael

              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