Qml Tableview Dynamic

[Solved] Qml Tableview Dynamic | Swift - Code Explorer | yomemimo.com
Question : qml TableView dynamic

Answered by : combative-cheetah-7ja5gd7pp49o

Component{ id: columnComponent TableViewColumn{width: 30 }
}
TableView { id: tableView model: listModel property var titles: somethingDynamic property var curTitles: { var t=[] for(var i=0;i<columnCount;i++){ t.push(getColumn(i).title) } return t } onTitlesChanged:{ for(var i=0;i<titles.length;i++){ if(curTitles.indexOf(titles[i])==-1){ var column = addColumn(columnComponent) column.title=titles[i] column.role=titles[i] } } for(var i=curTitles.length-1;i>=0;i--){ if(titles.indexOf(curTitles[i])==-1){ removeColumn(i) } } }
}

Source : https://stackoverflow.com/questions/27230818/qml-tableview-with-dynamic-number-of-columns | Last Update : Mon, 07 Jun 21

Question : qml tableview dynamic

Answered by : combative-cheetah-7ja5gd7pp49o

Component
{ id: columnComponent TableViewColumn{width: 100 }
}
TableView { id: view anchors.fill: parent resources: { var roleList = myModel.customRoleNames var temp = [] for(var i=0; i<roleList.length; i++) { var role = roleList[i] temp.push(columnComponent.createObject(view, { "role": role, "title": role})) } return temp } model: myModel

Source : https://stackoverflow.com/questions/27230818/qml-tableview-with-dynamic-number-of-columns | Last Update : Mon, 07 Jun 21

Answers related to qml tableview dynamic

Code Explorer Popular Question For Swift