Apparently the issue which cause this little edit line edit is because I use padding in QLineEdit in the stylesheet :
{
...
padding: 2px;
}
QLineEdit
{
...
padding: 2px;
}
To copy to clipboard, switch view to plain text mode
Looks like a bug from Qt to not compute the size correctly from QLineEdit.
Where is the best place to set the size manually or maybe possible to create the editor QLineEdit widget manually with a lookup on the actual style of QLineEdit ?
I tried to change the sizeHint of the item in the QStyledItemDelegate but I only got bigger item, the editor widget is not resized.
EDIT:
Here the hack found to avoid the Qt issue :
virtual void updateEditorGeometry
( QWidget* editor,
const QStyleOptionViewItem
& option,
const QModelIndex
& index
) const override
{
// Init the item option.
initStyleOption( &itemOption, index );
// Move the rect top value to avoid the height issue, 1px of padding on the top and bottom.
Geom.setTop( Geom.top() - 1 );
// Set the geometry.
editor->setGeometry( Geom );
}
virtual void updateEditorGeometry( QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index ) const override
{
// Init the item option.
QStyleOptionViewItem itemOption = option;
initStyleOption( &itemOption, index );
// Move the rect top value to avoid the height issue, 1px of padding on the top and bottom.
QRect Geom = QApplication::style()->subElementRect( QStyle::SE_ItemViewItemText, &itemOption, editor );
Geom.setTop( Geom.top() - 1 );
// Set the geometry.
editor->setGeometry( Geom );
}
To copy to clipboard, switch view to plain text mode
Bookmarks