1
votes

I created a tablewidget like this:

Tablewidget

I want to edit cell(0) value, (double click), but the edit box was too big and it covers cell(1):

Tablewidget2

How do I avoid the edit box covering the cell after it?

1
call table->resizeColumnsToContents(); resizeColumnsToContents - Simon
I add table->resizeColumnsToContents(); but the editbox still too big to cover the cell after it。 - Stone

1 Answers

0
votes

You should make your own children QStyledItemDelegate and redefine QStyledItemDelegate::createEditor method.

Something like that:

QWidget * MyStyledItemDelegate::createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const 
{
    QWidget * editor = QStyledItemDelegate::createEditor(parent, option, index);
    editor->setWidth( 20 ); // Handle editor here.
    return editor;
}