Hello,

Consider the following main.qml code, which works perfectly:

Qt Code:
  1. import QtQuick 2.4
  2. import QtQuick.Controls 1.3
  3. import QtQuick.Window 2.2
  4.  
  5. ApplicationWindow {
  6. title: qsTr("Hello Middle-Earth")
  7. width: 640
  8. height: 480
  9. visible: true
  10.  
  11. VisualDataModel {
  12. id: fellowship
  13.  
  14. model: ListModel {
  15. ListElement {
  16. name: "Aragorn"
  17. desc: "Ranger"
  18. }
  19. ListElement {
  20. name: "Frodo"
  21. desc: "Ring-bearer"
  22. }
  23. ListElement {
  24. name: "Gandalf"
  25. desc: "Wizard"
  26. }
  27. }
  28. delegate: Text {
  29. width: ListView.width
  30. text: name + " - " + desc
  31. }
  32. }
  33.  
  34. ListView {
  35. model: fellowship
  36. anchors.fill: parent
  37. }
  38. }
To copy to clipboard, switch view to plain text mode 

Now consider the following, custom VisualDataModel type, MyVisualDataModel.qml:

Qt Code:
  1. import QtQuick 2.4
  2.  
  3. VisualDataModel {
  4.  
  5. property Component innerDelegate: null
  6.  
  7. delegate: Loader {
  8. id: loader
  9.  
  10. sourceComponent: innerDelegate
  11. }
  12. }
To copy to clipboard, switch view to plain text mode 

Here is how I want to use that type in main:

Qt Code:
  1. MyVisualDataModel {
  2. id: fellowship
  3.  
  4. model: ListModel {
  5. ListElement {
  6. name: "Aragorn"
  7. desc: "Ranger"
  8. }
  9. ListElement {
  10. name: "Frodo"
  11. desc: "Ring-bearer"
  12. }
  13. ListElement {
  14. name: "Gandalf"
  15. desc: "Wizard"
  16. }
  17. }
  18. innerDelegate: Text {
  19. width: ListView.width
  20. text: name + " - " + desc
  21. }
  22. }
To copy to clipboard, switch view to plain text mode 

And here is what happens:

qrc:/main.qml:30: ReferenceError: name is not defined
qrc:/main.qml:30: ReferenceError: name is not defined
qrc:/main.qml:30: ReferenceError: name is not defined

How do I access model data in a Loader?

Update: plugging my question into Google before pressing submit here led me to this question on Stack Overflow. It appears to work perfectly; see below.

in main.qml:
Qt Code:
  1. innerDelegate: Text {
  2. width: ListView.width
  3. text: modelData.name + " - " + modelData.desc
  4. }
To copy to clipboard, switch view to plain text mode 

in MyVisualDataModel.qml:
Qt Code:
  1. delegate: Loader {
  2. id: loader
  3.  
  4. property variant modelData: model
  5.  
  6. sourceComponent: innerDelegate
  7. }
To copy to clipboard, switch view to plain text mode 

Posting for posterity.