ScrollView can't detect custom contentItem without an id.
Unsolved
QML and Qt Quick
-
Hi,
I'm using Qml 2.9.
I have a simple ScrollView with a custom contentItem (width a custom property) and a Button. When I click on the Button, I expect to display the custom property from the contentItem.
Here is my code:
Window { visible: true width: 300 height: 150 title: qsTr("Tests") ScrollView { id: scrollView height: 150 contentItem: Flickable { property int myTest: 42 } Button { text: "Click me"; onClicked: console.log(scrollView.contentItem.myTest) } } }
When I click on the button, I got the following output : "qml: undefined".
Now, I add an id to my custom contentItem:
Window { visible: true width: 300 height: 150 title: qsTr("Tests") ScrollView { id: scrollView height: 150 contentItem: Flickable { id: myFlickable property int myTest: 42 } Button { text: "Click me"; onClicked: console.log(scrollView.contentItem.myTest) } } }
And now, when I click on the button, I got the expected output: "qml: 42".
My question is: Why my Flickable is not detected by the ScrollView if I don't put any id ???
-
This post is deleted!