Using Stylesheets deterministicly
-
Hello Folks,
i´m still not sure about how to use stylesheets.
Example:
I managed to give a slider a custom appearance by this
https://www.dropbox.com/s/qf9iewysg021qey/styleSheet.jpg?dl=0QSlider:: => Selector / NameSpace Identifier
groove => SubControl Identifier
horizontal => ?
{"string"} => declaration, for example {color: red} What is "color", what is "red"?If i also place a BoxWidget and define it with a "Box" apearance via the corresponding enum,
how do i know- which subcontrols are existing and how they are named,
- what kind of identifier is "horizontal"
- which pairs can be set up in a declaration
From here
http://doc.qt.io/qt-5/stylesheet-reference.html
i found that QFrame supports the box model, but where do i know from- which elements of the QFrame are corresponding to margin, border, padding, content;
- which subcontrols are existing and
- which declaration pairs i can use and
- what are the elements which are "horizontal" at the Slider?
best regards,
Moe -
If i also place a BoxWidget and define it with a "Box" appearance via the corresponding enum
What is a BoxWidget and what enum do you mean?
As for the questions:
which subcontrols are existing and how they are named
Go here, find the widget you're interested in on the list and all supported subcontrols are listed there in a short description. You can click on the example link in each to see how they can be used. There's also a reverse list - all subcontrols and which widgets they are part of.
what kind of identifier is "horizontal"
Not that a name gives you anything, but they are called pseudo-states. It refers to a state of a control, for example a checkbox that is checked or unchecked, a button is enabled or disabled etc.
which pairs can be set up in a declaration
Most of the widgets support box model, so this means stuff like padding, margin, border, background-color or border-radius. The list of all possible properties is listed here. Which particular ones are supported on given control depends on its type. For example label wil have color (the color of text). If there's text there's gonna be font property. It's all rather common sense based. There's no list of every property for every control (that I know of) because it would be hugely redundant. The set of possible properties is not that long and rather self-explanatory.
Apart from the built-in properties you can have your custom ones. If you define a property in your QObject based class using Q_PROPERTY macro you can access that with stylesheets, e.g. if you define a property called "mycolor" you can access it with qss like this:qproperty-mycolor: #FFF
What is "color", what is "red"?
Color is a property. It's either a built-in property or a custom one. "red" is a value of that property. The syntax depends on the type of the property. For color it's either one of these. For a width it's gonna be a number, for "text" it's gonna be a string etc. It's all taken from CSS language.
which elements of the QFrame are corresponding to margin, border, padding, content;
What elements? QFrame doesn't have any elements. It's a simple rectangle and the box model defines how it is painted by the painter in paintEvent. Every control is basically a rectangle. It can have sub-controls that are rectangles too e.g. the up/down arrows in a spin box. There's nothing more to it.
The rest of the questions are repeats of the above if I'm not mistaken?