[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.

    @class CheckBoxDelegate : public QItemDelegate
    explicit CheckBoxDelegate(QObject *parent=0);

    virtual void drawCheck(QPainter *painter, const QStyleOptionViewItem &option,
        const QRect &, Qt::CheckState state) const;
    virtual bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option,
        const QModelIndex &index);
    virtual void drawFocus(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect) const;


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

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.