I want to highlight all of the cells in my table that have the same value in the first column, but have a different value in any other cell. So, for example, if I have two records in my table:
test, 25, 15, 45
test, 25, 5, 45
I would want to highlight the values 15 and 5.
I have tried the following code, but the text I get from the item calls is always "test" regardless of what item I am accessing.
// Highlight differences in the data
for( int row=0; row < ui->table_Data->rowCount(); row++ )
{
qDebug() << "going through rows";
for( int remaining_rows=row+1; remaining_rows < ui->table_Data->rowCount(); remaining_rows++)
{
qDebug() << "going through remaining rows";
for( int column=0; column<ui->table_Data->columnCount(); column++ )
{
qDebug() << "going through columns";
qDebug() << row << ":" << remaining_rows << column;
qDebug() << ui->table_Data->itemAt(row,column)->text();
qDebug() << ui->table_Data->itemAt(remaining_rows,column)->text();
if( ui->table_Data->itemAt(row,column)->text().compare(ui->table_Data->itemAt(remaining_rows,column)->text()) != 0)
{
qDebug() << "data does not match";
ui->table_Data->item(row,column)->setBackground(Qt::yellow);
ui->table_Data->item(remaining_rows,column)->setBackground(Qt::yellow);
}
}
}
}