Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.6.0
-
None
Description
In this document(https://doc.qt.io/qt-6/qml-qtquick-loader.html#receiving-signals-from-loaded-objects), there's a sentence :
it could also directly call any function defined in the Loader or its parent Item.
But the part "or its parent Item" is not clear.
I did a little experiment like this:
// Main.qml import QtQuick Window { width: 640 height: 480 visible: true title: qsTr("Hello World") Item { id: itm width: 200; height: 200 function helloItem() { console.log("hello from Item") } Loader { x: 50 function hello() { console.log("hello from Loader") } source: "Loded.qml" } } }
import QtQuick Rectangle { width: 100 height: 100 color: "red" x: 150 Component.onCompleted: { hello() helloItem() } }
The point of this experiment is that Loader has a parent "Item" with a function helloItem().
But calling it yields this error:
// output
qml: hello from Loader
qrc:/loaderAnchorTest/Loded.qml:10: ReferenceError: helloItem is not defined
Which seems to be contradicting "or its parent Item."
The issue here seems that the definition of "its parent Item" is not clear enough.
I think the documentation should be fixed in a way that it'll make it clear.