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. Highlight of an ListView
Forum Updated to NodeBB v4.3 + New Features

Highlight of an ListView

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 1 Posters 1.3k 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.
  • ? This user is from outside of this forum
    ? This user is from outside of this forum
    Guest
    wrote on last edited by
    #1

    Hi, I'm using a ListView wich is shown in an Rectangle an have a problem with the quantity of shown ListModelElements.

    My ListModel includes 8 elements but I only want to show 4 of them.

    @
    Rectangle {
    width: 340
    height: 339

    ListView {
    ...

    delegate: Component {
    Item {
    width: 340
    height: 85
    }
    }

    }
    }
    @

    My First problem, I want to show 4 Items. 4* 85 = 340. But when I use height 340 instead of 339 for my Rectangle then always 5 elements shown.
    Is using height 339 the best way to show only 4 Elements?

    Second Problem is, when at start only 4 Elements shown and I navigate the highlight to the fourth Element, then the fifth Element is shown automatically.
    Is it possible to prevent this?

    I use Qt 5 alpha and QtQuick 2.0.

    Thank You for your help.

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

      By default no item in QtQuick clips its content. In the case of views, this means that delegates outside the area of the view may be visible. You can solve this by setting 'clip: true' on the ListView. You can then set the height to 340, and this will fix the scrolling issue when the 4th element becomes the currentItem.

      1 Reply Last reply
      0
      • ? This user is from outside of this forum
        ? This user is from outside of this forum
        Guest
        wrote on last edited by
        #3

        It works,

        Thank you very much.

        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