Styling QML without manually marking each property to be styled

前端 未结 2 1998
慢半拍i
慢半拍i 2020-12-24 07:59

I know that QML does not support CSS styling like widgets do, and I have read up on alternative approaches to styling/theming:

  • https://qt-project.org/wiki/QmlS
2条回答
  •  时光说笑
    2020-12-24 08:20

    It could also be helpful to look at Qt Quick Controls Styles

    When using Controls Styles it is not necessary to explicitly assign each property in the target control. All properties can be defined in a separate [ControlName]Style component (e.g. ButtonStyle).
    Then in target component (e.g. Button) you can just reference to style component in one line of code.

    The only one downside here is that Style components are available for Qt Quick Controls only. Not for any Qt Component.

提交回复
热议问题