I'm doing an implementation of a CheckBox that inherits from QitemDelegate, to put it into a QTableView.

the problem is that I get when inserted flush left and I need it centered.

Far as the method that is responsible for the Paint. I have it written as follows:

void CheckBoxDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
bool checkValue;

QStyleOptionButton BtnStyle;
BtnStyle.state = QStyle::State_Enabled;

if(index.model()->data(index, Qt::DisplayRole).toBool() == true)
BtnStyle.state |= QStyle::State_On;
checkValue = true;
BtnStyle.state |= QStyle::State_Off;
checkValue = false;

BtnStyle.direction = QApplication::layoutDirection();
BtnStyle.rect = option.rect;
QApplication::style()->drawControl(QStyle::CE_CheckBox,&BtnStyle,painter );
QApplication::style()->drawControl(QStyle::CE_CheckBox,&BtnStyle,painter );


what is missing to appear centered?