Unsolved How to change color border QComboBox only?
-
I have QComboBox
, I change color it by code
combobox->setStyleSheet( "border: 1px solid red;" );
button down-row is change and height small too
how to change only color? -
@vinh not surprising, you have with that overwritten all default stylesheet settings and only specified an universal border
take a look at this extensive stylesheet example, what else you can modify in combination with what selector
https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qcombobox
-
@J-Hilk tks, I'm try
combobox->setStyleSheet( "QComboBox {border: 1px solid red;}" );
but it set all, what is correct syntax?
-
Hi,
When you use style sheets you have to do the complete styling. Style sheets ignores the original style used to draw the controls.
-
@SGaist So is there any other way? full styling is unnecessary for only border color.
-
Depending on what you want to use that border color for you could consider using a QRubberBand.
-
Hi
You could also put the QComboBox in a QFrame+layout.
(set all margins on layout to zero)
-
@mrjj yes, I have formLayout and I'm try set margin 0px but it not work.
-
@vinh
Ok I used a horizontal layout.
and sat all these to zero
-
@mrjj thank you very much, but QComboBox is change size and icon down-row, css on Qt not support custom only property :( I think
-
@vinh
Hi
Make sure to set the style sheet on the QFrame (ONLY)
and change it so it says
"QFrame {border: 1px solid red;}"So you don't affect the Combobox inside. but only the QFrame.
So no stylesheet on Combobox but only on QFrame.