janus
28th May 2008, 19:56
Hi,
I get a bool from the database and would like to display an image instead. But returning a Pixmap (or Icon) shows an empty cell. If i return the pic for the DecorationRole it is displayed. Any idea?
I have a subclass of QSqlQueryModel an the data() funktion looks like this:
QVariant SqlQueryModel::data(const QModelIndex & index, int role) const
{
QString curr(QSqlQueryModel::data(index, Qt::DisplayRole).toString());
if ( index.column() == 2 && role == Qt::DisplayRole ){
// return QVariant(QString("sometext")); // is displayed
return QVariant(QPixmap(":/somepic.png")); // is not displayed
}else{
return QSqlQueryModel::data(index, role);
}
}
I get a bool from the database and would like to display an image instead. But returning a Pixmap (or Icon) shows an empty cell. If i return the pic for the DecorationRole it is displayed. Any idea?
I have a subclass of QSqlQueryModel an the data() funktion looks like this:
QVariant SqlQueryModel::data(const QModelIndex & index, int role) const
{
QString curr(QSqlQueryModel::data(index, Qt::DisplayRole).toString());
if ( index.column() == 2 && role == Qt::DisplayRole ){
// return QVariant(QString("sometext")); // is displayed
return QVariant(QPixmap(":/somepic.png")); // is not displayed
}else{
return QSqlQueryModel::data(index, role);
}
}