Advertisement
vitimiti

QML XML Parsing Undefined

Aug 22nd, 2014
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. ERROR:
  2.  
  3. file:///home/vitimiti/workspace/CheetaHCS/tabs/HospitalTab.qml:103: TypeError: Cannot read property 'name' of undefined
  4.  
  5. ===================================================
  6.  
  7. XML FILE:
  8.  
  9. <?xml version="1.0" encoding="UTF-8" ?>
  10. <HospitalTab>
  11. <HospitalInformation>
  12. <name>Hospital El Bierzo</name>
  13. </HospitalInformation>
  14. </HospitalTab>
  15.  
  16. ====================================================
  17.  
  18. QML FILE:
  19.  
  20. import QtQuick 2.0
  21. import QtQuick.XmlListModel 2.0
  22. import Ubuntu.Components 0.1
  23.  
  24. import "../tools"
  25.  
  26. Tab {
  27. id: hospitalTab
  28. objectName: "hospitalTab"
  29.  
  30. anchors {
  31. margins: root.margins
  32. }
  33.  
  34. title: i18n.tr("About Us")
  35.  
  36. // This will hide all pages and show the intro one
  37. Component.onCompleted: {
  38. hospitalPage0.visible = true
  39. }
  40.  
  41. XmlListModel {
  42. id: hospitalTabNameModel
  43. objectName: "hospitalTabNameModel"
  44.  
  45. source: "../XML/HospitalTab.xml"
  46.  
  47. query: "/HospitalTab/HospitalInformation"
  48.  
  49. XmlRole {
  50. name: "hospitalName";
  51. query: "name/string()"
  52. }
  53. }
  54. ActivityIndicator {
  55. objectName: "activityIndicator"
  56. anchors.right: parent.right
  57. running: hospitalTabNameModel.status === XmlListModel.Loading
  58. }
  59.  
  60. // Intro page
  61. page: Page {
  62. id: hospitalPage0
  63. objectName: "hospitalPage0"
  64.  
  65. anchors {
  66. centerIn: parent
  67. }
  68.  
  69. width: parent.width
  70.  
  71. tools: HospitalTools {
  72. objectName: "hospital_tools"
  73. }
  74.  
  75. Flickable {
  76. id: cheetahcsFlickable
  77. objectName: "cheetahcsFlickable"
  78.  
  79. clip: true
  80. anchors.fill: parent
  81. contentHeight: hospitalColumn.height
  82. contentWidth: parent.width
  83. flickableDirection: Flickable.HorizontalAndVerticalFlick
  84.  
  85. Column {
  86. id: hospitalColumn
  87. objectName: "hospitalColumn"
  88.  
  89. anchors {
  90. centerIn: parent
  91. }
  92.  
  93. width: parent.width
  94. height: parent.height
  95. spacing: root.spacing
  96.  
  97. Label {
  98. width: parent.width
  99. horizontalAlignment: Text.Center
  100. wrapMode: Text.Wrap
  101.  
  102. function getHospital(model) {
  103. var hospitalName = model.get(0).name
  104. return hospitalName
  105. }
  106.  
  107. text: i18n.tr("Welcome to " + getHospital(hospitalTabNameModel) + "'s home screen.")
  108. }
  109. }
  110. }
  111. }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement