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. Strange values of contentY property of ListView

Strange values of contentY property of ListView

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 1.1k 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.
  • F Offline
    F Offline
    FOXLISIN
    wrote on last edited by
    #1

    Hi to all! I have noticed a strange behaviour of contentY property of ListView.

    And i watch for contentY property like this:

    onContentYChanged: {
        console.log( "---> " + contentY )
    }
    

    1: i have a list with C++ model with 15 elements
    http://s33.postimg.org/8tcx86xbz/image.png

    contentY at the top of list view is 0 (as expected)

    2: scroll this list view to bottom
    http://s33.postimg.org/f5x62oj7j/image.png

    contentY at this position is 220 (as expected)

    3: click "prepend" button (i prepend 8 items to model) and scroll to top:
    http://s33.postimg.org/c47avh3y7/image.png

    And now contentY at the top of ListView is -400! But it should be 0?

    Is it qml bug or my misunderstanding?

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by A Former User
      #2

      Hi @FOXLISIN!

      Is it qml bug or my misunderstanding?

      It's the latter. To cite the docs (Flickable QML Type):

      originX : real

      These properties hold the origin of the content. This value always refers to the top-left position of the content regardless of layout direction.
      This is usually (0,0), however ListView and GridView may have an arbitrary origin due to delegate size variation, or item insertion/removal outside the visible region.

      So you need to include originX, originY, contentHeight and contentWidth in your calculations.

      F 1 Reply Last reply
      0
      • ? A Former User

        Hi @FOXLISIN!

        Is it qml bug or my misunderstanding?

        It's the latter. To cite the docs (Flickable QML Type):

        originX : real

        These properties hold the origin of the content. This value always refers to the top-left position of the content regardless of layout direction.
        This is usually (0,0), however ListView and GridView may have an arbitrary origin due to delegate size variation, or item insertion/removal outside the visible region.

        So you need to include originX, originY, contentHeight and contentWidth in your calculations.

        F Offline
        F Offline
        FOXLISIN
        wrote on last edited by FOXLISIN
        #3

        @Wieland Thank you friend! It really helped me!

        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