[Interest] XYZ is instantiated recursively
Nuno Santos
nunosantos at imaginando.pt
Thu Jan 15 13:31:10 CET 2015
Dmitry,
I was able to do recursive instantiation using the following technic (actual code).
However, i’m having problems when the model is updated. With a single level everything is ok. If there is recursion, when the model is deleted, it crashes. Don’t know why.
Flow {
id: flow
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
spacing: 5
Repeater {
id: repeater
delegate: Component {
id: cc
Item {
width: flow.width
height: 200
Rectangle {
id: label
width: 40
anchors.left: parent.left
height: 200
color: "#333333"
border.color: "black"
border.width: 1
radius: 2
Text {
id: labelText
color: "white"
text: modelData.name
font.family: mainFont.name
font.pixelSize: 12
font.capitalization: Font.AllUppercase
rotation: -90
anchors.top: parent.bottom
width: label.height-icon.height-35
anchors.topMargin: -15
anchors.left: parent.left
anchors.leftMargin: 10
transformOrigin: Item.TopLeft
elide: Text.ElideRight
}
}
Flickable {
anchors.left: label.right
anchors.leftMargin: 10
anchors.right: parent.right
height: 200
contentWidth: label.width+row.childrenRect.width
clip: true
Row {
id: row
height: 180
Repeater {
id: parametersList
model: modelData.parameters
delegate: ModuleLaunchpadDeviceParameter {
height: 200
parameter: modelData
}
}
ListView {
id: chainsList
model: modelData.chains
width: 100
height: 200
spacing: 5
delegate: Rectangle {
width: 100
height: 40
color: "green"
MouseArea {
anchors.fill: parent
onClicked: chainsList.currentIndex=index
}
}
}
Repeater {
id: chainsDevicesList
model: chainsList.count>0?chainsList.model[chainsList.currentIndex].devices:0
delegate: cc
}
}
}
}
}
}
}
Thanks,
Regards,
Nuno
> On 15 Jan 2015, at 10:06, Nuno Santos <nunosantos at imaginando.pt> wrote:
>
> Dimitry,
>
> You are right. Let’s start by the model.
>
> My model is made of devices which can have list of devices (recursive model).
>
> I want to list A’s so I do something like:
>
> ListView {
> model: model.devices
> delegate: Device {
> parameters: modelData.parameters
> devices: modelData.devices
> }
>
> // Device.qml
>
> Rectangle {
> id: root
>
> property alias parameters: parameters.model
> property alias devices: devices.model
>
> ListView {
> id: parameters
> }
>
> Device {
> id: devices
>
> }
> }
>
> Qml output: Device is istantiated recursively
>
> Regards,
>
> Nuno
>
>> On 15 Jan 2015, at 10:00, Dmitry Volosnykh <dmitry.volosnykh at gmail.com <mailto:dmitry.volosnykh at gmail.com>> wrote:
>>
>> Nuno, it is sometimes hard to get an idea of what exactly you are trying to do without any minimal sample code provided.
>>
>> On Thu, Jan 15, 2015 at 12:57 PM, Nuno Santos <nunosantos at imaginando.pt <mailto:nunosantos at imaginando.pt>> wrote:
>> Hi,
>>
>> I’m building a QML UI interface for a model that can have a recursive behaviour
>>
>> I’m trying to instantiate a custom module inside a custom module and it is saying XYZ is instantiated recursively.
>>
>> Why does this error doesn’t occur when you instantiate a Rectangle inside a Rectangle? Isn’t that the same?
>>
>> If I really want the same module to appear to model that by it’s own is recursive, what should I do? I cannot have a different Qml file for each recursive depth as I don’t know what will be the total depth of it. And it simply doesn’t make sense…
>>
>> Any ideas?
>>
>> Thanks,
>>
>> Nuno Santos
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org <mailto:Interest at qt-project.org>
>> http://lists.qt-project.org/mailman/listinfo/interest <http://lists.qt-project.org/mailman/listinfo/interest>
>>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150115/76e025d8/attachment.html>
More information about the Interest
mailing list