Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-90251

How to custom palette for controls in the custom style plugin

    XMLWordPrintable

Details

    • All

    Description

      I found the commit https://github.com/qt/qtdeclarative/commit/1875ad7f92cad270cc5857d71096a4b46c27c562, is refactor the palette for QtQuick.
      In a custom style plug-in, how should I set the default color palette for a certain type of control? such as:

      Unable to find source-code formatter for language: qml. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      eg: custom style Slider.qml
      import QtQuick.Templates as T
      import QtQuick.Controls.CustomStyle as MyStyle
      
      T. Slider {
          id: control
          // palette: MyStyle.sliderPalette
          background: Rectangle {
              color: control.palette.background
              // color: MyStyle.sliderBackground
          }
      }
      

      By default, this Slider control will inherit the palette from the parent item, but I want it to have a different background color, maybe I can set the palette property for T.Slider, like "palette: MyStyle.sliderPalette", but in current, I need to resolve MyStyle.sliderPalette according to the palette of the parent item, by the palette background color of parent item to judgment it is Dark or Light color. I found that in the Material plug-in, It gave up using the palette of T.Slider, but directly used "Material.accentColor" to set the color for the Rectangle of the background item. This is usually It is not a good way. When MyStyle is set as the default plugin by the system, the user will found that the palette colors he set for Slider in the codes does not working.

      Attachments

        1. qtbug90251.zip
          3 kB
        2. qtbug90251-zccrs.zip
          4 kB
        3. qtbug90251-zccrs2.zip
          6 kB
        4. screenshot-1.png
          screenshot-1.png
          52 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            zccrs JiDe Zhang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes