PDA

View Full Version : using drawCheck() to customize checkbox in QTableView



nimaweb
9th August 2009, 14:16
Hi folks,
My QTableView is shown in the picture below. As you see the Online column and the Locked column are checkable.
http://i31.tinypic.com/xer13n.jpg
But what I'm having difficulty with is how to customize the check indicator. I want my QTableView like what is shown in the following picture (it's gimped):
http://i30.tinypic.com/2aakmeo.jpg
As you already might have guessed, I should implement this protected function in my delegate:

void QItemDelegate::drawCheck ( QPainter * painter, const QStyleOptionViewItem & option, const QRect & rect, Qt::CheckState state ) const
As you can see, I want to show two different images (actually four) considering which column is being rendered. But drawCheck doesn't provide any argument which shows which column is being rendered (like a QModelIndex). :confused:

nimaweb
9th August 2009, 15:27
I created two separate subclass from QItemDelegate and it's working fine :) I used QAbstractItemView::setItemDelegateForColumn() method.
Thanks!