[Qt-qml] What´s the correct QML type for arrays?
Cornelius Hald
hald at icandy.de
Thu Aug 19 14:54:36 CEST 2010
Hi,
I´m wondering whether or not 'variant' is the correct type used for
arrays in QML. Before going into longish explanations I´ll give some
striped-down example code.
// Slide.qml
Item {
property string title
}
// SlideShow.qml
Item {
property string title
property variant slides
}
// ExampleSlideShow.qml
SlideShow {
title: "My first slide show"
slides: [
Slide { title: "My first picture" },
Slide { title: "My second picture" }
]
}
// main.qml
Rectangle {
property variant slideShowData: ExampleSlideShow{}
width: 400
height: 200
Text {
id: title
text: "Slide Show Title: " + slideShowData.title
}
Text {
text: "Slide Title: " + slideShowData.slides[0].title //<<<
anchors.top: title.bottom
}
}
The statement "slideShowData.slides[0].title" is not working. because
"slideShowData.slides[0]" is always undefined.
If I debug the code, I see that "slideShowData.slides" actually points
to the last added 'Slide' component. So it´s not even an array.
Can someone explain to me why it is like this and what the correct way
of solving this issue would be?
Thank you very much!
Conny
More information about the Qt-qml
mailing list