Problems with Open-Source Downloads read and

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" ( - 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!


  • What event handlers for CalendarStyle are you referring to? I can't seem to find any in the doc.

  • 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:

  • Well the resultant control will be a composite control. For the most part the sub-controls should be styled appropriately, or can be set to an existing style. Only if you want to deviate from a style would you have have to worry about styling.

  • The custom widgets I'm making are not entirely composed of stylable controls. Some are just a collection of text, graphics, and canvases into a new kind of widget.

  • Text: QLabel
    Graphics... Outta Luck.
    Canvases... Outta Luck.

    I would say get acquainted with QPalette and use the system colors where appropriate.

  • Aren't you just supposed to set the public properties which determine the visuals of the calendar? The event handlers are there for the Calendar to "work", but we as users should only worry about the visuals.

Log in to reply