bar0n
4th March 2009, 12:19
As the title says... i have a qitemdelgate which creates a QCheckBox as editor for some items. how can i center this editor in the cell of the qtableview where the editor shows up.
here`s the method i wrote so far
QWidget* QmitkDataStorageDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option
, const QModelIndex &index) const
{
if (index.column() == m_VisibilityColumnIndex)
{
//option.decorationAlignment = Qt::AlignCenter;
//option.decorationAlignment = Qt::AlignCenter;
QCheckBox* visibilityCheckBox = new QCheckBox(parent);
connect(visibilityCheckBox, SIGNAL(editingFinished()),
this, SLOT(commitAndCloseEditor()));
return visibilityCheckBox;
}
else
{
return QItemDelegate::createEditor(parent, option, index);
}
}
here`s the method i wrote so far
QWidget* QmitkDataStorageDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option
, const QModelIndex &index) const
{
if (index.column() == m_VisibilityColumnIndex)
{
//option.decorationAlignment = Qt::AlignCenter;
//option.decorationAlignment = Qt::AlignCenter;
QCheckBox* visibilityCheckBox = new QCheckBox(parent);
connect(visibilityCheckBox, SIGNAL(editingFinished()),
this, SLOT(commitAndCloseEditor()));
return visibilityCheckBox;
}
else
{
return QItemDelegate::createEditor(parent, option, index);
}
}