How to elided text of all comboBox items?
Unsolved
General and Desktop
-
Hi,
Please look at this:
https://stackoverflow.com/questions/41360618/qcombobox-elided-text-on-selected-item
I would like the same, but not for QComboBox EditLine, but for QComboBox items. I tried change option.text in
void myStyledItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
but with no result.
-
@JonB my Bad :)
void myStyledItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { QStyleOptionViewItem optionV4 = option; initStyleOption(&optionV4, index); optionV4.text="textAfterChange"; QStyledItemDelegate::paint(painter,optionV4,index); }
-
Item delegates only works on item views, in your case, the popup view of the combo box.
If you want to change the painting of combo box's current text, then it must be done inpaintEvent()
of the combo box.
If you are talking about the items in the popup view, then I don't understand because they should be elided by default. (If you use your own item view, checkQAbstractItemView::textElideMode
.)