0

I want to partially change the style of a control without affecting it's rendering otherwise. Let's take a button as an example and create a MyButton.qml containing:

Button {
    id: mybutton

    style: ButtonStyle {
          label: Text {
            renderType: Text.NativeRendering
            font.family: "Helvetica"
            font.pointSize: 20
            text: control.text
          } 
    }
}

Expected: a system theme colored button with an ugly font in it. Got: default-styled button ignoring the system palette (while the rest of the application is themed fine)

Why does the overriding style ignore the system palette? What is the right way to do it?

EDIT: Example: Normal button vs "styled" button

Mav
  • 60
  • 6
  • Try [SystemPalette](http://doc.qt.io/qt-5/qml-qtquick-systempalette.html) – folibis Feb 13 '17 at 06:59
  • I can use Systempalette to set the label's color, but what about the color of the button outline? I didn't override it, why has it changed? – Mav Feb 13 '17 at 07:03
  • What controls do you use - 2.0 or 1.4? What OS and Qt versions are? Can you please provide images of expected and current buttons? – folibis Feb 13 '17 at 07:45
  • As for style overriding - the Button item has default style (see it [here](https://github.com/qt/qtquickcontrols/blob/dev/src/controls/Button.qml#L94) ) so when you assign your custom style you override it and lose all defaults. – folibis Feb 13 '17 at 07:54
  • @folibis Controls 1.4, Arch linux with current Plasma themed "Breeze Dark". I assumed that by deriving from "ButtonStyle" I am deriving from the default style and only overriding the "label" property while leaving the default "control" and "background". The default style implementation seems to reference the SystemPalette. Could you explain the use of "Settings.styleComponent" in the default implementation? PS Added a screenshot. – Mav Feb 13 '17 at 09:25

0 Answers0