QTreeWidget/QListWidget: Edit gives QLineEdit too little on the height
Hi,
Using QTreeWidget or QListWidget I have too little height when I edit items, it's surely a common issue, giving the rename hard to do.
What is the best way to solve this issue ? Because set the size manually is maybe an option but Qt has something automatic to solve that ?
Thanks
Re: QTreeWidget/QListWidget: Edit gives QLineEdit too little on the height
No automatic resize while editing, have to do it explicitly.
Re: QTreeWidget/QListWidget: Edit gives QLineEdit too little on the height
Apparently the issue which cause this little edit line edit is because I use padding in QLineEdit in the stylesheet :
Code:
{
...
padding: 2px;
}
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 :
Code:
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 );
}