Without subclassing can I have in QComboBox text that will be shown where no selection was made, something like setPlaceholderText in QLineEdit?
A combobox can be populated using the insert functions, insertItem() and insertItems() for example. Items can be changed with setItemText(). An item can be removed with removeItem() and all items can be removed with clear().
A QComboBox provides a means of presenting a list of options to the user in a way that takes up the minimum amount of screen space. A combobox is a selection widget that displays the current item, and can pop up a list of selectable items. A combobox may be editable, allowing the user to modify each item in the list.
QComboBox does not have a placeholder text option but you can achieve this in two ways:
myCombo->lineEdit()->setPlaceholderText("Some text");
But this
will only work if your combobox is editable.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With