demo3.qml 488 B

12345678910111213141516171819202122232425262728
  1. import QtQuick 1.0
  2. /**
  3. * You can use Component.onCompleted and Component.onDestroy to do some pre and post-processing
  4. */
  5. Rectangle {
  6. width: 300
  7. height: 300
  8. PersistentObject {
  9. id: simpleObject
  10. property int counter
  11. Component.onCompleted: {
  12. counter++; // Increase counter *after* loading.
  13. }
  14. Component.onDestruction: {
  15. counter = 1000; // Has no effect, as the object is already saved
  16. }
  17. }
  18. TextInput {
  19. text: simpleObject.counter
  20. }
  21. }