{
Q_OBJECT
public:
~PostDelegate(){}
{
if(index.model()->hasChildren(index) && index.column() < 2 ) { //GroupProxyRecord
QItemDelegate::drawBackground(painter , option , index
) ;
//draw bagground first if(index.column() == 1) { //redirect to column 0
idx = index.sibling(index.row() , 0) ;
}
QSize s
= sizeHint
(opt , idx
) ;
QString value
= idx.
data().
toString() ;
QRectF rectF
= painter
->boundingRect
( opt.
rect , Qt
::AlignLeft, value
) ;
painter->drawText(rectF, value );
} else {
}
}
{
}
};
class PostDelegate : public QItemDelegate
{
Q_OBJECT
public:
PostDelegate(QObject *parent=0) : QItemDelegate(parent){}
~PostDelegate(){}
void paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const
{
if(index.model()->hasChildren(index) && index.column() < 2 ) { //GroupProxyRecord
QItemDelegate::drawBackground(painter , option , index) ; //draw bagground first
QModelIndex idx = index;
if(index.column() == 1) { //redirect to column 0
idx = index.sibling(index.row() , 0) ;
}
QStyleOptionViewItem opt ;
QSize s = sizeHint(opt , idx) ;
QString value = idx.data().toString() ;
QRectF rectF = painter->boundingRect ( opt.rect , Qt::AlignLeft, value ) ;
painter->drawText(rectF, value );
} else {
QItemDelegate::paint(painter , option , index) ;
}
}
QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const
{
return QItemDelegate::sizeHint(option, index);
}
};
To copy to clipboard, switch view to plain text mode
Bookmarks