QComboBox - how to change text size ( pixels )
TomNow99 last edited by TomNow99
I will start with picture:
I have QComboBox with QStandardItemModel and QStandardItems. That items have different long texts. For example here, one of my item has text:
item->setText("very, very, very, very, very, very, very, very, very, very, very long text");
I would like to display the shorter text. For example:
That green arrow is only to show, where I would like to have free, white space ( right side from arrow ).
But when the user click on item I would like get full text. How can I do that?
In initStyleOption() in delegate to item I write:
QFont myFont(QFont(option->font)); QFontMetrics fm(myFont); QString elidedText= fm.elidedText(index.data().toString(),Qt::ElideMiddle, 120); option->text=elidedText;
But now I have other question:
This is one of my item in QComboBox. Width of this is 200, but the width, where I can display text is smaller, because the checkbox has a few pixels for self ( look at next picture and red line - this is that place, where I can't have text ).
So I would like to get width the item in comboBox where I can have text ( so width of comboBox minus width of red line ).