QStyledItemDelegate does a nice job and renders the item using the correct size of the items contents. But when I start editing then the spinbox decoration hides the contents. I’d like to change this behavior so that the content is always visible.(see image 1)
I subclassed QStyledItemDelegate::updateEditorGeometry to change the width of the editor
QSize ExtraSize
= QSize(option.
rect.
width()+ option.
decorationSize.
width(),option.
rect.
height());
QRect ExtraRect
= option.
rect;
ExtraRect.setSize(ExtraSize);
editor->setGeometry(ExtraRect);
QSize ExtraSize= QSize(option.rect.width()+ option.decorationSize.width(),option.rect.height());
QRect ExtraRect = option.rect;
ExtraRect.setSize(ExtraSize);
editor->setGeometry(ExtraRect);
To copy to clipboard, switch view to plain text mode
But this doesn’t give the expected results. When debugging I see that decorationSize remains the same, even when using larger fonts.
With QFont fff("Arial",12);
debugging output : option.decorationSize.width() 16
(see image 2)
With QFont fff("Arial",32);
debugging output : option.decorationSize.width() 16
(see image 3)
QUESTION : Can anyone tell me which approach I should use to get the correct size of the decoration?
Or should I make a custom style instead of using delegates?
Bookmarks