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

Qt Quick Controls: Palette role values don't get live updates

    XMLWordPrintable

Details

    • 95637da9a (dev), b89b83124 (6.7), 67311f932 (6.6), 76bb485d4 (tqtc/lts-6.5)

    Description

      Code

      import QtQuick
      import QtQuick.Layouts
      import QtQuick.Controls.Basic
      
      ApplicationWindow {
          id: window
          width: 600
          height: 300
          visible: true
          palette: paletteButton.checked ? grayscalePalette : coloredPalette
      
          property color accentColor: Qt.color(Qt.hsla(slider_color.value, 0.5, 0.5))
      
          Palette {
              id: grayscalePalette
      
              window: "white"
              windowText: "black"
              buttonText: "black"
              button: "lightgrey"
              text: "black"
              dark: "black"
              mid: "black"
              midlight: "black"
              light: "black"
              highlight: "black"
              highlightedText: "black"
          }
          Palette {
              id: coloredPalette
      
              window: "white"
              windowText: window.accentColor
              buttonText: window.accentColor
              button: "lightgrey"
              text: window.accentColor
              dark: window.accentColor
              mid: window.accentColor
              midlight: window.accentColor
              light: window.accentColor
              highlight: window.accentColor
              highlightedText: window.accentColor
          }
      
          GridLayout {
              anchors.fill: parent
              columns: 3
      
              Label { text: "Palette" }
              Button {
                  id: paletteButton
                  checkable: true
                  text: checked ? "Grayscale" : "Colored"
              }
              Item { Layout.fillWidth: true }
      
              Label { text: "Color" }
              Slider { id: slider_color }
              Rectangle {
                  color: window.accentColor
                  Layout.preferredWidth: 20
                  Layout.preferredHeight: 20
              }
          }
      }
      

       

      Outcomes

      • When the "Color" slider is moved around, the little square changes color in real-time (Expected) but the controls always remain at the initial color (Not expected)
      • If you click the "Palette" button twice, then the control colors now match the little square's color (until you change the slider value again)

       

      Workaround
      Manually force the palette to reload whenever the color changes:

      onAccentColorChanged: {
          if (!paletteButton.checked) {
              paletteButton.checked = true
              paletteButton.checked = false
          }
      }
      

      Attachments

        For Gerrit Dashboard: QTBUG-121388
        # Subject Branch Project Status CR V

        Activity

          People

            santhoshkumar Santhosh Kumar Selvaraj
            skoh-qt Sze Howe Koh
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes