I have a QComboBox with different texts. I want to display only the most right characters of the texts since each text represent a long file name.
How to right justify my texts in the QComboBox?
Printable View
I have a QComboBox with different texts. I want to display only the most right characters of the texts since each text represent a long file name.
How to right justify my texts in the QComboBox?
You could try using the QComboBox::setItemData() method with the Qt::TextAlignmentRole and a value of Qt::AlignRight | Qt::AlignVCenter. I do not know if the combo box will obey this, but it is worth a try.
You could also create a left-elided string using QFontMetrics::elidedText() if you know the width of the text field in the combo box.
Checkout Bookmarc's solution:
http://www.qtforum.org/article/20839...qcombobox.html