October 27, 2011

pmjz pmjz
Lab Rat
89 posts

[Self-Solved]QTableView selected row color

 

Hi, guys

I create a delegate for checkbox, and display this checkBox in Qtableview. everything is ok, but, when I selected one row in table, there is no selected color in that specific columns that checkbox are displayed. would you guys please give me some ideas on this issue, thanks a lot.

  1. class CheckBoxDelegate : public QItemDelegate
  2. {
  3.     Q_OBJECT
  4. public:
  5.     explicit CheckBoxDelegate(QObject *parent=0);
  6.  
  7.     virtual void drawCheck(QPainter *painter, const QStyleOptionViewItem &option,
  8.         const QRect &, Qt::CheckState state) const;
  9.     virtual bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option,
  10.         const QModelIndex &index);
  11.     virtual void drawFocus(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect) const;
  12. };

1 reply

October 28, 2011

pmjz pmjz
Lab Rat
89 posts

just reimplements the drawdisplay() in the delegate and make drawfocus() is empty function.

 
  ‹‹ XML parsing problem (error triggered by consumer)      Problem with QSplitter - won’t resize widgets? [Fixed] ››

You must log in to post a reply. Not a member yet? Register here!