Closed Haiyang-Bian closed 5 months ago
How can I use the "insertRow" and "setRow" when I using a model in my component with qml? I've tried jsonObject and there dosen't have this method, I've tried Vector and got "DimensionMismatch: array could not be broadcast to match destination". My code is as follows:
import QtQuick 2.0
import QtQuick.Controls 2.15
import QtQuick.Window
Window {
id: window
width: 700
height: 700
visible: true
ComboBox {
model: tList
textRole: "name"
valueRole: "type"
width: 200
height: 50
currentIndex: 0
onCurrentIndexChanged: {
tList.removeRow(currentIndex)
tList.insertRow(currentIndex,{
name: "New Item",
type: "New Type"
})
}
delegate: ItemDelegate {
width: parent.width
height: 40
contentItem: Row {
spacing: 10
Text {
text: name
font.pixelSize: 20
verticalAlignment: Text.AlignVCenter
}
}
}
}
}
Hi, regarding TableViewColumn
: this was a QtQuick.Controls version 1 component and it is removed in Qt 6.
Inserting and removing rows with the Julia item model is shown in these examples:
ListView
)
There is also the tableview test that shows the full functionality, but it's a little less readable:
Thanks, the second example of tableview
helps me a lot!
When I use 'TableViewColumn' in the section of 'TableView', I got the following error: "TableViewColumn is not a type". How can I settle this promblem without changing the way to building a table? My code is as follows: