Results 1 to 1 of 1

Thread: Changing ListView model property during a sequential animation

  1. #1
    Join Date
    Jan 2014
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Changing ListView model property during a sequential animation

    Hi,
    Okay, here is a simple example of the behavior. When I set the “model” property of the listView between the two NumberAnimations I am hoping the list contents will change to those from model2. However, when I hit the “up arrow” key there are no errors thrown and the list is not visible.
    I feel like I am using PropertyAction incorrectly, but I don’t know what I am doing wrong. I tried putting model2 in quotes but that did not work either.
    Thanks

    Qt Code:
    1. import QtQuick 2.0
    2. import QtQuick.Window 2.1
    3.  
    4. Rectangle {
    5. id: mainView
    6. width: Screen.desktopAvailableWidth
    7. height: Screen.desktopAvailableHeight
    8. color: "black"
    9.  
    10. ListModel {
    11. id: model1
    12.  
    13. ListElement {
    14. name: "Apple"
    15. }
    16. ListElement {
    17. name: "Orange"
    18. }
    19. ListElement {
    20. name: "Banana"
    21. }
    22. }
    23.  
    24. ListModel {
    25. id: model2
    26.  
    27. ListElement {
    28. name: "Avacado"
    29. }
    30. ListElement {
    31. name: "Tomato"
    32. }
    33. ListElement {
    34. name: "Onion"
    35. }
    36. }
    37.  
    38.  
    39. Component {
    40. id: listDelegate
    41.  
    42. Column {
    43. Text { color: "white"; text: name; font.pointSize: 36 }
    44. }
    45. }
    46.  
    47.  
    48. ListView {
    49. id: listView
    50. spacing: 50
    51. anchors.fill: parent
    52. model: model1
    53. delegate: listDelegate
    54. width: Screen.desktopAvailableWidth - 50;
    55. height: Screen.desktopAvailableHeight;
    56.  
    57. SequentialAnimation {
    58. id: seqAnim
    59.  
    60. NumberAnimation { target: listView; property: "opacity"; to: 0; duration: 1000 }
    61.  
    62. PropertyAction { target: listView; properties: "model"; value: model2 }
    63.  
    64. NumberAnimation { target: listView; property: "opacity"; to: 1; duration: 1000 }
    65.  
    66. }
    67.  
    68.  
    69. focus: true
    70. Keys.onUpPressed: {
    71. seqAnim.running = true;
    72. }
    73.  
    74.  
    75. }
    76.  
    77. }
    To copy to clipboard, switch view to plain text mode 


    Added after 21 minutes:


    Hi,

    I removed the PropertyAction line and replaced with ScriptAction {script: listView.model = model2;}

    That seems to work.
    Last edited by brduffy; 31st January 2014 at 17:11.

Similar Threads

  1. ListView problem with c++ model
    By nick85 in forum Qt Quick
    Replies: 7
    Last Post: 12th September 2013, 10:33
  2. Replies: 1
    Last Post: 23rd June 2012, 14:23
  3. Animation on ListView::move
    By wladek in forum Qt Quick
    Replies: 1
    Last Post: 9th March 2011, 10:47
  4. Combining sequential and parallel animation
    By mirelon in forum Qt Programming
    Replies: 0
    Last Post: 22nd January 2010, 16:28
  5. Replies: 2
    Last Post: 10th August 2009, 10:45

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.