{
if ( index.column() == 0 )
{
QString imgFile
= index.
model()->data
( index, Qt
::DisplayRole );
if ( Qt::DisplayRole == role )
{
}
if ( !QFile::exists( imgFile
)) {
imgFile = "/home/dev/ttm/content/ttmad.jpg";
}
if ( role == Qt::DecorationRole )
{
return pixmap;
}
if(role == Qt::SizeHintRole)
{
return pixmap.size();
}
}
return index.model()->data( index, role );
}
QVariant testdata::data(const QModelIndex &index, int role) const
{
if ( index.column() == 0 )
{
QString imgFile = index.model()->data( index, Qt::DisplayRole );
if ( Qt::DisplayRole == role )
{
return QString();
}
if ( !QFile::exists( imgFile ))
{
imgFile = "/home/dev/ttm/content/ttmad.jpg";
}
QPixmap pixmap( imgFile );
if ( role == Qt::DecorationRole )
{
return pixmap;
}
if(role == Qt::SizeHintRole)
{
return pixmap.size();
}
}
return index.model()->data( index, role );
}
To copy to clipboard, switch view to plain text mode
first i get
//testdata.cpp:58: error: conversion from ‘QVariant’ to non-scalar type ‘QString’ requested
Bookmarks