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] Items showed out of QListview range
QtWS25 Last Chance

[solved] Items showed out of QListview range

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

    This is my headache:

    !http://www.zoonman.ru/files/qt/s0.png(screenshot)!

    @

    import QtQuick 1.1

    Rectangle {
    width: parent.width - x -5
    height: parent.height - 250
    color: "#6e2535"
    radius: 10
    border.color: "#50000000"
    Component {
    id: highlight
    Rectangle {
    width: parent.width; height: 32
    color: "#2e262c"; radius: 5
    y: list_view1.currentItem.y
    }
    }

    Rectangle {
    id: scrollbar
    anchors.right: list_view1.right
    y: list_view1.visibleArea.yPosition * list_view1.height
    width: 10
    height: list_view1.visibleArea.heightRatio * list_view1.height
    color: "#fff"
    opacity: 0.1
    z: 3
    radius: 5
    }

    ListView {
    id: list_view1
    highlightRangeMode: ListView.ApplyRange
    preferredHighlightBegin: list_view1.height/2 - 36
    preferredHighlightEnd: list_view1.height/2 + 36
    keyNavigationWraps: true
    focus: true
    highlightFollowsCurrentItem: false
    maximumFlickVelocity: 5000 // влияет на скорость скроллинга
    highlight: highlight
    boundsBehavior: Flickable.StopAtBounds
    transformOrigin: Item.Top
    cacheBuffer: 10000
    width: parent.width
    height: parent.height
    contentWidth: parent.width-22
    contentHeight: 300
    delegate: Item {
    x: 5
    height: 32
    focus: true
    id: item1
    Row {
    id: row1
    Rectangle {
    width: parent.width
    height: 32
    border.color: "#000000"
    border.width: 1
    Image {
    x:2
    y:4
    id: nameImage
    width: 24
    height: 24
    source: ((sourcePath) ? sourcePath : "../../music/Afrojack/cover.jpeg")
    smooth: true
    }
    Text {
    focus: true
    x: 32
    text: name
    id: playlistTitle
    anchors.verticalCenter: parent.verticalCenter
    font.pointSize: 18
    MouseArea {
    focus: true
    anchors.fill: parent
    onClicked: {
    list_view1.highlightMoveSpeed = 10000
    list_view1.currentIndex = index;
    }
    }
    color: "#f6d7b1"
    }
    Rectangle {
    x:100
    width: parent.width - 100
    height: parent.height- 2
    anchors.fill: parent
    border.color: "#000000"
    }
    }
    }
    }
    model: ListModel {
    id: myModel
    ListElement {
    name: "Pendulum - The Island"
    colorCode: "grey"
    sourcePath: "../../music/Selena Gomez/cover.jpeg"
    }
    ListElement {
    name:"Ирина Салтыкова - Trust In You"
    colorCode: "red"
    sourcePath: "../../music/Ирина Салтыкова/cover.jpeg"
    }
    ListElement {
    name: "Selena Gomez & The Scene - Who Says (Bimbo Jones Radio Edit)"
    colorCode: "blue"
    }
    /* there are a lot of items */
    ListElement {
    name: "Red"
    colorCode: "red"
    }
    ListElement {
    name: "Blue"
    colorCode: "blue"
    }
    ListElement {
    name: "Green"
    colorCode: "green"
    }
    ListElement {
    name: "Grey"
    colorCode: "grey"
    }
    ListElement {
    name: "Pendulum - The Island"
    colorCode: "grey"
    sourcePath: "../../music/Selena Gomez/cover.jpeg"
    }
    ListElement {
    name:"Ирина Салтыкова - Trust In You"
    colorCode: "red"
    sourcePath: "../../music/Ирина Салтыкова/cover.jpeg"
    }
    }
    }
    }

    @

    How I can hide Items which out of Rectangle range?

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

      "Clipping":http://doc.qt.nokia.com/4.7-snapshot/qml-item.html#clip-prop would be the key.

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        zoonman
        wrote on last edited by
        #3

        Thank you sir! I just missed it in documentation. This is my fault.

        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