I want to distinguish the placeholder text of a QComboBox
using QStyleSheet
by drawing the placeholder with a different color.
With Qt6, it's easy to set the placeholder text to a combo box from code if the combo box is editable:
if(someCondition)
myComboBox->lineEdit()->setPlaceholder("Some placeholder");
else
myComboBox->lineEdit()->setPlaceholder("Some other placeholder");
So far so good, but if I use a custom stylesheet, so the default grayish placeholder is gone, and it is drawn with the color
property. I tried to filter by some property based on this question, but I was not successful.
This is the relevant part of the dark-theme stylesheet:
auto styleSheet = "QWidget {color: white; background-color: #505050}"
"QComboBox[text=\"\"] { color: #808080 }";
myComboBox->setStyleSheet(styleSheet);
Currently, this is the result, with white letters:
And this is the expected with a sightly gray color:
Also, I tried to filter to the QComboBox
, to the QComboBox[currentText=\"\"]
but no success.