Qt5/C++ - QComboBox - change currrent text color and the dropdown text colour
Qt Creator 3.6.1 - Based on Qt 5.6.0 (MSVC 2013, 32 bit) - Windows 10
Hello,
Code:
qApp->setStyleSheet("QGroupBox, QComboBox, QRadioButton, QPushButton, QLabel, QLineEdit"
"{ color: blue }"); // text colour
ui->myComboBox->setStyleSheet("QListView { color: blue; }");
ui->myComboBox->setStyleSheet("QComboBox { background-color: white }");
I'm trying to set the text colour and the dropdown list text colour on a QComboBox.
I tried changing the order and it seems that the last setStyleSheet is the one that takes effect.
How do I apply both to the QComboBox?
Regards
Re: Qt5/C++ - QComboBox - change currrent text color and the dropdown text colour
The last two are obviously exclusive, since the stylesheet in line 5 overwrites the one set in line 4.
Are you saying that the rule set in line 1 and the rule set in line 5 are not both active?
Cheers,
_
Re: Qt5/C++ - QComboBox - change currrent text color and the dropdown text colour
Hello anda_skoa,
Thanks for your reply,
Quote:
The last two are obviously exclusive
I gathered that from my test.
I can get lines 1 & 5 working.
I can get lines 1 & 4 working.
What I would like to is get line 1 and lines 4 & 5 working together.
I can't work out the syntax required.
Regards
Re: Qt5/C++ - QComboBox - change currrent text color and the dropdown text colour
You need to combine the two strings into one.
Two calls to a setter function will always result in the second value being the current value.
Cheers,
_
Re: Qt5/C++ - QComboBox - change currrent text color and the dropdown text colour
Hello,
Many thanks, this seems to work.
Code:
ui->myComboBox->setStyleSheet("QComboBox { background-color: white }" "QListView { color: blue; }");
Regards