विगेट्स में "क्लासनाम()" विधि है जो मेटा ऑब्जेक्ट के माध्यम से सुलभ है। मेरे मामले में यह है:
slider.metaObject()->className();
// ==> mimas::Slider
के बाद से "स्लाइडर" वर्ग एक नाम स्थान में है, तो आप (के साथ की जगह '::' '-') स्टाइल के लिए पूरी तरह से योग्य नाम का उपयोग करना:
.slider { background-color:blue; }
सी ++ स्लाइडर वर्ग:
mimas--Slider { background-color:blue; }
एक अन्य समाधान एक वर्ग संपत्ति को परिभाषित करने और एक प्रमुख बिंदु के साथ इसका इस्तेमाल करने की है
पर
// background-color:
palette.color(QPalette::Window)
// color:
palette.color(QPalette::WindowText)
// border-width:
// not possible (too bad...). To make it work, you would need to copy paste
// some headers defined in qstylesheetstyle.cpp for QRenderRule class inside,
// get the private headers for QStyleSheetStyle and change them so you can call
// renderRule and then you could use the rule to get the width borders. But your
// code won't link because the symbol for QStyleSheetStyle are local in QtGui.
// The official and supported solution is to use property:
// qproperty-border:
border_width_ // or whatever stores the Q_PROPERTY border
और अंत में, एक नोट:
Q_PROPERTY(QString class READ cssClass)
...
QString cssClass() { return QString("slider"); }
विषय पर, रंग और शैलियों सीएसएस में परिभाषित के साथ स्लाइडर आकर्षित करने के लिए है, यह कैसे तुम उन्हें (link text) है सीएसएस से QPalette मूल्य:
color = QPalette::WindowText
background = QPalette::Window
alternate-background-color = QPalette::AlternateBase
selection-background-color = QPalette::Highlighted
selection-color = QPalette::HighlightedText
क्या आपने आईडी की कोशिश की है (यानी #blah {...}) या कक्षा (यानी .schmarr {...}) चयनकर्ता? – DwB