October 11, 2011

dmoliaster dmoliaster
Lab Rat
1 posts

Contact list example doesn’t work as expected

 

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:

  1. Rectangle{    
  2.     width: 800; height: 200
  3.     color: "lightblue"
  4.  
  5.     Rectangle {
  6.         width: 300; height: 200; color: "white"
  7.  
  8.         ListModel {
  9.             id: nameModel
  10.             ListElement { name: "Alice"; file: "star.svg" }
  11.             ListElement { name: "Bob"; file: "night.svg" }
  12.             ListElement { name: "Jane"; file: "star.svg" }
  13.             ListElement { name: "Harry"; file: "star.svg" }
  14.             ListElement { name: "Wendy"; file: "night.svg" }
  15.         }
  16.  
  17.         Component {
  18.             id: nameDelegate
  19.             Item {
  20.                 id: delegateItem
  21.                 width: parent.width
  22.                 height: 28
  23.  
  24.                 states: State {
  25.                     name: "current"
  26.                     when: ListView.isCurrentItem
  27.                     PropertyChanges {
  28.                         target: delegateItem
  29.                         height: 44
  30.                     }
  31.                 }
  32.                 transitions: Transition {
  33.                     NumberAnimation {
  34.                         properties: "height"
  35.                         duration: 300
  36.                         easing.type: "InOutQuint"
  37.                     }
  38.                 }
  39.  
  40.                 Text {
  41.                     text: name
  42.                     font.pixelSize: parent.height - 4
  43.                     anchors.left: parent.left
  44.                     anchors.verticalCenter: parent.verticalCenter
  45.                 }
  46.                 Image {
  47.                     source: file
  48.                     fillMode: Image.PreserveAspectFit
  49.                     smooth: true
  50.                     sourceSize: Qt.size(64,64)
  51.  
  52.                     width: height; height: parent.height - 4
  53.                     anchors.right: parent.right
  54.                     anchors.verticalCenter: parent.verticalCenter
  55.                 }
  56.             }
  57.         }
  58.  
  59.         ListView {
  60.             id: listView
  61.             anchors.fill: parent
  62.  
  63.             model: nameModel
  64.             delegate: nameDelegate
  65.             focus: true
  66.             clip: true
  67.  
  68.             header: Rectangle {
  69.                 width: parent.width; height: 10;
  70.                 color: "#8080ff"
  71.             }
  72.             footer: Rectangle {
  73.                 width: parent.width; height: 10;
  74.                 color: "#8080ff"
  75.             }
  76.             highlight: Rectangle {
  77.                 width: parent.width; height: 10;
  78.                 color: "lightgray"
  79.             }
  80.         }
  81.  
  82.     }
  83. }

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?

2 replies

October 12, 2011

mbrasser mbrasser
Lab Rat
452 posts

Hi,

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

  1. 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

October 13, 2011

dmoliaster dmoliaster
Lab Rat
1 posts

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!

 
  ‹‹ How do I learn Qt Quick (QML) ?      How to find out the original Component name during runtime? ››

You must log in to post a reply. Not a member yet? Register here!