How to set QComboBox text elide mode
-
Is there a way to set the text elide mode for the text shown in a QComboBox (not the popup list)?
It is possible to set it for items in the popup list
@myCmb->view()->setTextElideMode()@
but I did not find any way to set it for the text shown in the QComboBox.
Thanks in advance for your help
-
For an editable combo box: certainly not. A QLineEdit is used, and that class can not elide text. For a non-editable I am not sure. I don't think so by default, but the source will tell you for sure.
However, you should be able to add this to the QComboBox using subclassing. The ingredients are all there, I think. I think that you can use QStyle to actually do most of the rendering for you (in the case of the non-editable combo, the editable one you just call the base implementation). You just need to use QFontMetrics to generate an elided current text to set in the QStyleOptionComboBox instance you pass to the QStyle for rendering.
However, also make a feature suggestion in Jira. I think it makes sense to have.