Results 1 to 2 of 2

Thread: Array's onChanged property doesn't get called when pushing items in it on mouseclicks

  1. #1
    Join Date
    Apr 2011
    Posts
    231
    Thanks
    141
    Thanked 6 Times in 5 Posts

    Default Array's onChanged property doesn't get called when pushing items in it on mouseclicks

    Access.qml

    Qt Code:
    1. import QtQuick 2.0
    2.  
    3. Rectangle {
    4. id: newq
    5.  
    6. width: 100
    7. height: 62
    8.  
    9. property var pp : [1]
    10.  
    11. onPpChanged:
    12. {
    13. console.log("\non pp changed, show pp's length: " + pp.length)
    14. }
    15.  
    16. property int inde : 0
    17.  
    18. MouseArea
    19. {
    20. anchors.fill: parent
    21. onClicked:
    22. {
    23. pp.push (inde++)
    24. console.log("mousearea shows pp's length: " + pp.length)
    25. }
    26. }
    27. }
    To copy to clipboard, switch view to plain text mode 

    main.qml

    Qt Code:
    1. import QtQuick 2.0
    2.  
    3. Rectangle {
    4. id: root
    5. width: 360
    6. height: 360
    7.  
    8. Access
    9. {
    10. color: "red"
    11. }
    12. }
    To copy to clipboard, switch view to plain text mode 
    Output (on mouse clicks):

    Qt Code:
    1. QML debugging is enabled. Only use this in a safe environment.
    2.  
    3. on pp changed, show pp's length: 1
    4. mousearea shows pp's length: 2
    5. mousearea shows pp's length: 3
    6. mousearea shows pp's length: 4
    7. mousearea shows pp's length: 5
    To copy to clipboard, switch view to plain text mode 

    Why isn't the onPpChanged getting called when I push the items in pp? What can I do to get it called?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Array's onChanged property doesn't get called when pushing items in it on mousecl

    I guess the "var" type property does not change because you are not assigning a new array object.

    What kind of task are you trying to solve?

    Cheers,
    _

Similar Threads

  1. TypeError: Cannot read property 'length' of undefined in QML array
    By TheIndependentAquarius in forum Qt Quick
    Replies: 6
    Last Post: 12th June 2014, 06:39
  2. Slot doesn't get called
    By waynew in forum Qt Programming
    Replies: 7
    Last Post: 18th April 2010, 13:34
  3. How come this slot doesn't get called every second?
    By ShaChris23 in forum Qt Programming
    Replies: 2
    Last Post: 5th November 2009, 23:41
  4. Replies: 0
    Last Post: 17th September 2009, 10:40
  5. commitData doesn't seem to be called...
    By tone in forum Qt Programming
    Replies: 7
    Last Post: 10th September 2008, 14:42

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
  •  
Qt is a trademark of The Qt Company.