Hi,
is it possible to force the re-creation of a QML item (here: TableView)?
For a TableView (QuickControls 1.4), I use the resource property in the way shown below (shortened).
When I want to change the content of a header, this is not being updated/displayed. Of course, my model emits:
emit this->headerDataChanged(Qt::Horizontal,0,999);
emit this->headerDataChanged(Qt::Horizontal,0,999);
To copy to clipboard, switch view to plain text mode
I have tried binding in line 18 of the biggest code block :
"title": Qt.binding(function() { return tableModel.columnHeaderName(role) }),
"title": Qt.binding(function() { return tableModel.columnHeaderName(role) }),
To copy to clipboard, switch view to plain text mode
Unfortunately, "role" is always the highest number, not the respective appropriate one.
Calling update() does not help, toggling the visible property neither, even setting the model to undefined and back.
Can I trigger the creation process somehow? Or is there a different way to force it into diplaying a header change after creation?
Any help appreciated!
Cheers,
Sebastian
This is the (partial) code:
resources: {
var roleList = tableModel ? tableModel.userRoleNames : 0
var temp = []
var columnComponent
for(var i=0; i<roleList.length; i++) {
var role = roleList[i]
(!tableModel.isColumnHidden(role)) {
if
var columnHeaderName = tableModel.columnHeaderName(role)
if (tableModel.columnTypeName(role) === "QDate") {
columnComponent = columnComponentDate;
}
if (columnComponent) {
temp.push(columnComponent.createObject(
dynamicTableViewBasis, {
"role": role,
"title": columnHeaderName,
"width": tableModel.columnInitialWidth(role)
}))
}
}
}
return temp
}
resources: {
var roleList = tableModel ? tableModel.userRoleNames : 0
var temp = []
var columnComponent
for(var i=0; i<roleList.length; i++) {
var role = roleList[i]
(!tableModel.isColumnHidden(role)) {
if
var columnHeaderName = tableModel.columnHeaderName(role)
if (tableModel.columnTypeName(role) === "QDate") {
columnComponent = columnComponentDate;
}
if (columnComponent) {
temp.push(columnComponent.createObject(
dynamicTableViewBasis, {
"role": role,
"title": columnHeaderName,
"width": tableModel.columnInitialWidth(role)
}))
}
}
}
return temp
}
To copy to clipboard, switch view to plain text mode
As actual columns, I use components like this one:
Component {
id: columnComponentDate
QQC14.TableViewColumn {
delegate: Text {
id: dateDelegate
property date dateVar: styleData.value ? styleData.value : ""
text: dateVar ? appController.dateStringShort(dateVar) : ""
}
}
}
Component {
id: columnComponentDate
QQC14.TableViewColumn {
delegate: Text {
id: dateDelegate
property date dateVar: styleData.value ? styleData.value : ""
text: dateVar ? appController.dateStringShort(dateVar) : ""
}
}
}
To copy to clipboard, switch view to plain text mode
--
http://www.classintouch.de - Tablet-Software für Lehrer
Bookmarks