Hi all,
maybe this is a repetition but I just could not get ot working. My question is simple:
just wanted to make so cells in the QTableView colored when the data fulfill certain conditions.
atm, my code looks like this:
void MainInterface::colorWarning()
{
int rownumber;
for(rownumber=0;rownumber<=100; rownumber++) {
if (idindex.isValid()){
QString dateString
= idindex.
data().
toString();
QDate date
= QDate::fromString(dateString,
"yyyy-MM-dd");
int daysafter = date.daysTo(today);
if (daysafter >= 30) {
mui.tableViewPersonTable->model()->setData(idindex, Qt::green, Qt::BackgroundRole))
}
}
}
}
void MainInterface::colorWarning()
{
int rownumber;
for(rownumber=0;rownumber<=100; rownumber++) {
QModelIndex idindex = mui.tableViewPersonTable->model()->index(rownumber, 9, QModelIndex())
if (idindex.isValid()){
QString dateString = idindex.data().toString();
QDate date = QDate::fromString(dateString, "yyyy-MM-dd");
QDate today = QDate::currentDate();
int daysafter = date.daysTo(today);
if (daysafter >= 30) {
mui.tableViewPersonTable->model()->setData(idindex, Qt::green, Qt::BackgroundRole))
}
}
}
}
To copy to clipboard, switch view to plain text mode
thanks!!!
Bookmarks