Good afternoon,

I am developing an application using QML (Qt 5.8) where a TabView is used to control the different forms used. To reduce the number of Tab elements, I am using State in some tabs to control minor differences in the visible Tab content (depending on a test result for instance). I do assign a default state in each Tab, with state transitions are based on a Timer (declared in the Tab) or external test result. This approach works well for cases where a Timer (or external test) is started after a Tab is made current, and using onStateChanged().

Note that the TabView.tabsVisible is set to false.

There is however a case that is failing. The external test is executed in the background while Tab A is current. Depending on the test result Tab B becomes current (test passed), otherwise Tab C is selected to be current, with additional items specific to the test failure. The display the additional items is based on State (specific to Tab C). I have included a partial definition of Tab C

Qt Code:
  1. Item {
  2. id: sensorIntegrityTest
  3.  
  4. onEnabledChanged:
  5. {
  6. console.log( "sensorIntegrityTest.Item.onEnabledChanged, visible: ", visible, ", enabled: ", enabled)
  7. }
  8. onVisibleChanged:
  9. {
  10. console.log( "sensorIntegrityTest.Item.onVisibleChanged, visible: ", visible, ", enabled: ", enabled)
  11. }
  12.  
  13. property int imageShown : 0
  14.  
  15. states: [
  16. State {
  17. name: "integrity setup"
  18. PropertyChanges { target: sensorIntegrityTestFail; visible: false }
  19. PropertyChanges { target: sensorIntegrityTestPass; visible: false }
  20. },
  21. State {
  22. name: "integrity test"
  23. PropertyChanges { target: sensorIntegrityTestFail; visible: false }
  24. PropertyChanges { target: sensorIntegrityTestPass; visible: false }
  25. },
  26. State {
  27. name: "integrity failed"
  28. PropertyChanges { target: sensorIntegrityTestPass; visible: false }
  29. PropertyChanges { target: sensorIntegrityTestFail; visible: true }
  30. },
  31. State {
  32. name: "integrity passed"
  33. PropertyChanges { target: sensorIntegrityTestFail; visible: false }
  34. PropertyChanges { target: sensorIntegrityTestPass; visible: true }
  35. }
  36.  
  37. ]
  38. onStateChanged:
  39. {
  40. console.log( "sensorIntegrityTest.onStateChanged: state= ", state)
  41. if ("integrity test" === state) {
  42. integrityTestTimer.start()
  43. } else {
  44. integrityTestTimer.stop()
  45. }
  46. }
  47.  
  48. // Assign the default state
  49. state: "integrity setup"
To copy to clipboard, switch view to plain text mode 

I am using a JavaScript function to select the current Tab. When Tab C is selected the following content appears in the console log:
Qt Code:
  1. qml: sensorIntegrityTest.onStateChanged: state= integrity setup
To copy to clipboard, switch view to plain text mode 
When trying the read the state property value from the Javascript function using the command
Qt Code:
  1. console.log( "state ", tabView.getTab( nextIndex).sensorIntegrityTest.state)
To copy to clipboard, switch view to plain text mode 
the following error is reported: qrc:/screen.js:208: TypeError: Cannot read property 'state' of undefined

What am I missing? Is it possible to access the state property as currently declared here from a Javascript function?

My last attempt to address this issue, I defined an alias for the state variable in Tab C definition of using the statement
Qt Code:
  1. property alias integrityState: sensorIntegrityTest.state
To copy to clipboard, switch view to plain text mode 
resulting in the following error reported by the Javascript functions: qrc:/screen.js:211: Error: Cannot assign to non-existent property "integrityState"

Regards,
Daniel