Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.15, 6.0, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8.0 Beta1
-
None
Description
The placeholderText property of QComboBox, added in 5.15, has the following documentation:
"When this function is called before items are added the placeholder text will be shown,... When the QComboBox is editable, use QLineEdit::setPlaceholderText() instead."
QComboBoxPrivate::rowsInserted, if the current index is invalid, will switch to the first new valid index unless, per the above, the QComboBox placeholderText is set first, in which case it doesn't switch and the placeholder text is still shown. However, if the QComboBox is editable, it doesn't check the placeholderText of the associated QLineEdit. Instead, it switches to the first item when adding items instead of staying displayed on the placeholder text. That's confusing, because the documentation recommends using QLineEdit::setPlaceholderText() instead.
There is a fairly simple workaround - set the QComboBox placeholderText as well. it can be set to the same thing as the QLineEdit placeholderText (which is fine with implicit sharing), or to anything non-empty. It won't be displayed, it will just be used in that check. So the workaround isn't bad, but it's redundant and the documentation warns against doing it.