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. ListView rendering problem
Forum Updated to NodeBB v4.3 + New Features

ListView rendering problem

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

    Can someone tell me what's wrong with the current implementation?
    @import QtQuick 1.1
    import com.nokia.meego 1.0

    Page {
    tools: commonTools
    property string path: "/"
    function add_element(element){
    console.log(element.name)
    elements.append(element);
    }

    ListModel{
        id: elements
        ListElement{
            name: "prova"
        }
        ListElement{
            name: "gino"
        }
    }
    
    Flickable{
        anchors.fill: parent
        width: parent.width
        contentHeight: list.height
        ListView{
            id: list
            width: parent.width
            model: elements
            delegate: Item {
                signal clicked(string name)
                width: parent.width
                height: 100
                Label{
                    id: label
                    anchors.centerIn: parent
                    text: name
                    font: UiConstants.TitleFont
                }
                MouseArea{
                    anchors.fill: parent
                    onClicked: {
                        parent.clicked(name)
                    }
                }
                Rectangle{
                    width: parent.width
                    height: 2
                    color: "white"
                    anchors.bottom: parent.bottom
                }
            }
        }
    }
    
    Component.onCompleted: {
        add_element({"name": "test"})
    }
    

    }@

    When the list is displayed i can see only the first list item
    Thank You

    1 Reply Last reply
    0
    • F Offline
      F Offline
      favoritas37
      wrote on last edited by
      #2

      Why did you put the ListView inside the Flickable?
      Most probably it would result to unexpected behavior because the mouse events would be caught by the Flickable element not letting you select an element from the list. Also in the ListView you haven't set the height so probably this is why you can see only the first element.

      So, if you only want to use the ListView remove the Flickable and add the anchors.fill: parent to the ListView.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rferrazz
        wrote on last edited by
        #3

        You're right
        i did not know that the ListView is already scrollable. I thought it was like a Column.
        Thank you again!

        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