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. Contact list example doesn't work as expected
Qt 6.11 is out! See what's new in the release blog

Contact list example doesn't work as expected

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

    Hi there!
    I just downloaded the last SDK 1.1.3 (Qt 4.7.4) and i tried to run a few QML examples. Everything was fine until i tried next example:

    @Rectangle{
    width: 800; height: 200
    color: "lightblue"

    Rectangle {
        width: 300; height: 200; color: "white"
    
        ListModel {
            id: nameModel
            ListElement { name: "Alice"; file: "star.svg" }
            ListElement { name: "Bob"; file: "night.svg" }
            ListElement { name: "Jane"; file: "star.svg" }
            ListElement { name: "Harry"; file: "star.svg" }
            ListElement { name: "Wendy"; file: "night.svg" }
        }
    
        Component {
            id: nameDelegate
            Item {
                id: delegateItem
                width: parent.width
                height: 28
    
                states: State {
                    name: "current"
                    when: ListView.isCurrentItem
                    PropertyChanges {
                        target: delegateItem
                        height: 44
                    }
                }
                transitions: Transition {
                    NumberAnimation {
                        properties: "height"
                        duration: 300
                        easing.type: "InOutQuint"
                    }
                }
    
                Text {
                    text: name
                    font.pixelSize: parent.height - 4
                    anchors.left: parent.left
                    anchors.verticalCenter: parent.verticalCenter
                }
                Image {
                    source: file
                    fillMode: Image.PreserveAspectFit
                    smooth: true
                    sourceSize: Qt.size(64,64)
    
                    width: height; height: parent.height - 4
                    anchors.right: parent.right
                    anchors.verticalCenter: parent.verticalCenter
                }
            }
        }
    
        ListView {
            id: listView
            anchors.fill: parent
    
            model: nameModel
            delegate: nameDelegate
            focus: true
            clip: true
    
            header: Rectangle {
                width: parent.width; height: 10;
                color: "#8080ff"
            }
            footer: Rectangle {
                width: parent.width; height: 10;
                color: "#8080ff"
            }
            highlight: Rectangle {
                width: parent.width; height: 10;
                color: "lightgray"
            }
        }
    
    }
    

    }
    @

    The state and transition doesn't work and i don't know why. I checked out that "ListView.isCurrentItem" is always false on "when" property. When i run the same example using the previous version, it worked. So, what's happening here? Any ideas?

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

      Hi,

      Does it work if you change the when line to the following?

      @when: delegateItem.ListView.isCurrentItem@

      If this is a regression, it would be much appreciated if you could raise an issue at http://bugreports.qt.nokia.com .

      Regards,
      Michael

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dmoliaster
        wrote on last edited by
        #3

        Yes! It worked!!
        Thanks a lot Michael, i just sent a reply about the issue at https://bugreports.qt.nokia.com/browse/QTBUG-21855

        Best Regards!

        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