Hi,
Where is the model from - QML or C++? Could you maybe show us the model? Maybe something is wrong there?
Also you can shorten the color part a lot:
color: timeToReply > 15 ? "red" : "black"
color: timeToReply > 15 ? "red" : "black"
To copy to clipboard, switch view to plain text mode
EDIT:
I've tried it and yes I have the same problem, QtCreator gives me a ReferenceError, it seems it's not working like in a ListView. But it could be worked around by using ItemDelegate if you just want to change the text color, here you are reading the value from the Table (not the Role) and use it to modify the color. This way offers also a Table as always, without the need to rewrite all of the styling.
TableView {
id: table
anchors.fill: parent
model: testModel
TableViewColumn {role: "timeToReply"; title: "Reply timings"; width: 100}
itemDelegate: Item {
Text {
anchors.verticalCenter: parent.verticalCenter
color: parseInt(styleData.value) > 15 ? "red" : styleData.textColor // maybe it's also working without parseInt().
elide: styleData.elideMode
text: styleData.value
}
}
}
TableView {
id: table
anchors.fill: parent
model: testModel
TableViewColumn {role: "timeToReply"; title: "Reply timings"; width: 100}
itemDelegate: Item {
Text {
anchors.verticalCenter: parent.verticalCenter
color: parseInt(styleData.value) > 15 ? "red" : styleData.textColor // maybe it's also working without parseInt().
elide: styleData.elideMode
text: styleData.value
}
}
}
To copy to clipboard, switch view to plain text mode
AlphaX2
Bookmarks