Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QComboBox with static image
redlars last edited by
The QComboBox will when not in focus show the currently selected item using text and possibly an icon. How can I override this behaviour to show a static image when the ComboBox is not in focus. This is to reduce the space the button takes up. The perfect example is in Windows Explorer, there is a comboBox for View. The ComboBox just contains a simple generic icon but does not say anything about the selected view. Clicking on the button will show the four choices with dot infront of the selected choice.
How can this be done in Qt?
Jeroentjehome last edited by
You might want to check out the type of events that Qt can handle. For the given widget you might want to use this one:
@QEvent::FocusOut 9 Widget loses keyboard focus (QFocusEvent).@
Then in that event set the value to the one with the icon only to display. Tada, should work