Extending QML - Styling design principles?
-
Hi!
I am developing some custom widgets, and want to make the elements styleable in the same way many QML widgets are. I'm a little confused about what styling is exactly for, based on reading the documentation and source code.
First, not all QML widgets are styled. Is the plan to style them all? Is there a principle which defines what is/will be styled, and what isn't?
Second, styles in most cases define purely visual (non-interactive) units. In at least one case (CalendarStyle) it also defines interactions (with event handlers). Is the plan for QML for all styles to take in both interactive and visual elements of a widget? Or is Calendar an exception? A page listing the styles separates them into "Styling views" and "Styling controls" (http://qt-project.org/doc/qt-5/qtquickcontrolsstyles-index.html) - does this provide a clue as to the future direction?
Third, if visual and control elements are to be part of styles, what is left in the widget itself? The data model perhaps?
Fourth, a style may itself contain other styled elements. How might the styling of elements embedded in style be changed?
Fifth, is it intended that the styling convention is extended to custom QML components? Some useful infrastructure for styling is private in QML. Might this be made public in the future? What is the plan for using the style convention in custom components in QML - will it be better supported in the future?
All rather philosophical questions that can probably only be answered by the QML designers... I hope there are one or two about!
Cheers,
Ben. -
I'm looking at the source code for that. There are event handlers dealing with clicks on the days, amongst other things. You can't "style" those, they're just implemented there, for example:
https://qt.gitorious.org/qt/qtquickcontrols/source/d6b0dac2d2859e4f1c6f8bd0e147d16f43343784:src/controls/Styles/Base/CalendarStyle.qml#L575