Dear All:
New to Qt - and have created a Tableview from a SqlQuery Model. Problem is - If the Validity Column is > 1 I want
the entire row to be red...
I tried something like this but nothing happened...
void Edit_Log_Dialog::chk_Valid_Log_Line()
{
int validity;
for (int row = 1; row < current_Log_View->model()->rowCount(); row++)
{
chk_line = current_Log_View->model()->index(row,7);
validity = rfa_Log_Model->data(chk_line, Qt::DisplayRole).toInt();
if (validity > 1)
{
for (int i = 1; i< 8; i++)
{
chk_line = current_Log_View->model()->index(row,i);
rfa_Log_Model->setData(chk_line,rowColor,Qt::ForegroundRole);
}
}
}
}
void Edit_Log_Dialog::chk_Valid_Log_Line()
{
QModelIndex chk_line;
QColor rowColor = Qt::red;
int validity;
for (int row = 1; row < current_Log_View->model()->rowCount(); row++)
{
chk_line = current_Log_View->model()->index(row,7);
validity = rfa_Log_Model->data(chk_line, Qt::DisplayRole).toInt();
if (validity > 1)
{
for (int i = 1; i< 8; i++)
{
chk_line = current_Log_View->model()->index(row,i);
rfa_Log_Model->setData(chk_line,rowColor,Qt::ForegroundRole);
}
}
}
}
To copy to clipboard, switch view to plain text mode
I saw something about using QItemDelegate - but wondered if there was an easier way to do this, or do I have to create a subclass
or something - which I am a bit fuzzy about.
Thanks, Tb
Bookmarks