I've managed to reproduce the crash in the following code. The version of Qt i'm using is 4.7.4. Can anyone tell me why this would crash the program? Does it crash for anyone else?
import QtQuick 1.0
Rectangle {
id: main
width: 360
height: 360
Text {
id: addBtn
text: "Add to List"
anchors.top: parent.top
width: parent.width
height: 40
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
font.bold: true
MouseArea {
anchors.fill: parent
onClicked: {
list_model.append({"display": "Click me to delete me"})
}
}
}
ListView {
anchors.top: parent.top
anchors.topMargin: 40
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
spacing: 5
model: ListModel {
id: list_model
}
delegate: Rectangle
{
border.width: 1
border.color: "#000"
width: main.width - 1
height: delText.height + 8
MouseArea {
anchors.fill: parent
onClicked: {
list_model.remove(index)
}
}
Text {
id: delText
height: 20
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
text: display
}
}
}
}
import QtQuick 1.0
Rectangle {
id: main
width: 360
height: 360
Text {
id: addBtn
text: "Add to List"
anchors.top: parent.top
width: parent.width
height: 40
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
font.bold: true
MouseArea {
anchors.fill: parent
onClicked: {
list_model.append({"display": "Click me to delete me"})
}
}
}
ListView {
anchors.top: parent.top
anchors.topMargin: 40
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
spacing: 5
model: ListModel {
id: list_model
}
delegate: Rectangle
{
border.width: 1
border.color: "#000"
width: main.width - 1
height: delText.height + 8
MouseArea {
anchors.fill: parent
onClicked: {
list_model.remove(index)
}
}
Text {
id: delText
height: 20
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
text: display
}
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks