john_erlandsson
4th January 2012, 23:33
Hi!
I am experimenting with a subclass of QSqlQueryModel. Since I wanted to change the background color in the ListView, I reimplemented the data method
QVariant BrowseWoTableModel::data( const QModelIndex &item, int role ) const
{
if( role == Qt::BackgroundColorRole )
{
return Qt::green;
}
else if( role == Qt::DisplayRole )
{
return record( item.row() ).value( item.column() );
}
return QVariant();
}
This works for setting the background color, but fails in displaying the data.
What am I missing here?
//John
I am experimenting with a subclass of QSqlQueryModel. Since I wanted to change the background color in the ListView, I reimplemented the data method
QVariant BrowseWoTableModel::data( const QModelIndex &item, int role ) const
{
if( role == Qt::BackgroundColorRole )
{
return Qt::green;
}
else if( role == Qt::DisplayRole )
{
return record( item.row() ).value( item.column() );
}
return QVariant();
}
This works for setting the background color, but fails in displaying the data.
What am I missing here?
//John