Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Controls 1.4: Partially changing control style without discarding system palette

Controls 1.4: Partially changing control style without discarding system palette

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 588 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    EvilMav
    wrote on last edited by
    #1

    Hi,

    had no luck so far at stackoverflow, so I'm crossposting it here.

    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)
    example

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

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @EvilMav AFAIK overriding the style removes the default style. One way to make partial changes is to directly change in the source as described here

      The second way to create the button is good if you plan to use your rounded button in several places. It involves moving the code into its own QML file within your project.
      For this approach, we'll copy the background code from the default style's Button.qml. This file can be found in the following path in your Qt installation:
      $QTDIR/qml/QtQuick/Controls.2/Button.qml

      157

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved