سؤال

I have a class which inherits QComboBox. I need to set red border for this widget.
I can't use QPalette, I am trying to use setStyleSheet:
pComboBox->setStyleSheet("QFrame { border: 2px solid red; }")
It works fine for QLineEdit, but for QComboBox I got red border around popup view and not combo box.
How can I get access to the frame of QComboBox?

هل كانت مفيدة؟

المحلول 2

Ok, the easiest way, which I found to solve this problem is just to subclass widget I use and draw red rectangle in paintEvent().

نصائح أخرى

You should be using the QComboBox selector, not QFrame (or both if you want the two styled).

pComboBox->setStyleSheet("QComboBox { border: 2px solid red; } QFrame { border: 2px solid blue; }")

See the StyleSheet examples for more on styling that widget.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top