Style Settings in Qt Quick (+ Designer)

  • Hello,
    I am planning to write a set of custom components in a way that other people can use the QtCreator Design mode to create a Gui. I intend to create these components in different styles that can be switched from within the Design mode by inserting the name of a Style in some property field.(This is the most usable way I could come up with.)

    I cannot find a proper solution for this problem, all my approaches have some sort of flaw.

    1. Putting all the styles in contextProperties:

    -prohibits a style change in Design mode since contextProperty values cannot be accessed. All you get in Design mode is #contextPropertyName# if i am not mistaken.

    1. Creating a global javascript File (.pragma) that has all style values in variables and includes a function that takes a Stylename parameter that changes these variables to the correct values:
    • if a property is assigned a javascript variable a change of this variable will not trigger a "property changed event" as a change of this property from within qml would. Since all components have several style dependent properties. triggering these changes by hand seems excessive work to me.
      IS THERE A REPAINT ALL that could do that???

    • i also had trouble getting the function to change the variable values in Design mode

    1. I have a (kind of) working solution involving QtObjects holding style properties and a loader dynamically changing its source. But that would involve loading the Style Objects into every Component which might be bad for performance.


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.