On Wed, Mar 11, 2015 at 10:07 AM Marcus Ottosson <[email protected]>
wrote:

> But the part about the stylsheets being converted and not stored was
> definitely not right.
>
> What you’re seeing there is merely the last command put into setStyleSheet,
> it doesn’t actually represent the sum of each individual command.
> Technically, the string is cached internally, into a private member of
> QApplication and discarded each time it is set.
>
> You can prove that by setting it twice.
>
> app.setStyleSheet("QWidget { background-color: 'blue' }")
> app.setStyleSheet("QWidget { font: 'verdana' }")assert app.styleSheet() == 
> "QWidget { font: 'verdana' }"
>
> What’s more, it also doesn’t take into account stylesheets applied to
> children within widgets or the application.
>
Maybe this is just about expectations... because I had never had the
expectation that multiple calls to setStyleSheet would be incremental
changes to the previous stylesheet. I have always assume you are setting
the whole stylesheet. In which case, it is storing the stylesheet for that
object and using it as part of the cascading effect. "set" to me generally
means to replace the previous value with a new value.


> You can prove that by applying it to a widget first, and then application.
> As the widget is affected by the stylesheet, one might think it should be
> able to reproduce it.
>
> widget = QtWidgets.QWidget()
> app.setStyleSheet("QWidget { font: 'verdana' }")assert widget.styleSheet() == 
> ""
>
> Which means that unless you’re certain that the setStyleSheet command was
> used only once, on only one object - either the QApplication, or a QWidget,
> which are the only objects that carry this method - then it’s quite
> difficult to be certain that what you get is what’s actually being drawn.
>

Again, expectations I suppose. It is a cascading system, so if a specific
object never had a stylesheet value applied, then it only inherits from the
parent and has no additional modifications.


>  If you use a stylesheets it takes priority over a palette
>
> I think it’s more a matter of which gets set last.
>

Well, the documentation does suggest that stylesheets should not be mixed
with custom palettes:
http://qt-project.org/doc/qt-4.8/qwidget.html#palette-prop

So I presume that to mean non-deterministic behaviour. You either try to
fully go the stylesheet route, or custom palettes, is what I take away from
that. And based on my past experience of having some reference issues to
palette values in combination with stylesheets (as Tony had also
confirmed), I tend to believe the non-deterministic behaviour is real.


>  They are also supposedly a touch slower
>
> Then what? In the above example, four QPalette roles are being set with
> only one CSS directive. Some may argue that this would be faster than
> setting each role manually; at least when it’s done from Python.
>
> Maya is most likely using a custom QStyle/palette and not stylesheets.
>
> They not necessarily mutually exclusive. Some things may be more easily
> set using stylesheets, whereas others are easier/only possible via QPalette.
>
> It’s all in the source, folks.
> https://qt.gitorious.org/qt
>
See above


> ​
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAe6iLO2CM-xVc03k59zPLN65tpKDbuqX0-VdHY_2yoBw%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAe6iLO2CM-xVc03k59zPLN65tpKDbuqX0-VdHY_2yoBw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0RwchB_kkh4OPU79Cpsg1nhb54NNGxVnC4g65xsK0pWQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to