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. Override Material Style for an individual control?

Override Material Style for an individual control?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 1.6k Views 1 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.
  • I Offline
    I Offline
    igor_stravinsky
    wrote on last edited by
    #1

    I've set my QtQuick Controls 2 app to use Material style.

    As an unfortunate side effect of this, all button text is capitalized, even if text is set to a lowercase string.

    Is there a way to override the style set in the qtquickcontrols2.conf file for a particular control, so I can add lowercase text to my button?

    1 Reply Last reply
    0
    • I Offline
      I Offline
      igor_stravinsky
      wrote on last edited by
      #2

      Well...I found one solution...if I override the contentItem for the button

      contentItem: Text {
              text: myButton.text
              font.family:"helvetica"
              font.pointSize:16
              opacity: enabled ? 1.0 : 0.3
              color: control.down ? "#17a81a" : "#21be2b"
              horizontalAlignment: Text.AlignHCenter
              verticalAlignment: Text.AlignVCenter
              elide: Text.ElideRight
          }
      

      But if I simply set the font to be myButton.font, then I'll get capitalized text.

      Is there a simpler way to override the Material Style?

      1 Reply Last reply
      0
      • jpnurmiJ Offline
        jpnurmiJ Offline
        jpnurmi
        wrote on last edited by jpnurmi
        #3

        The default font follows the Material Design guidelines:

        Button text should be capitalized in languages that have capitalization.

        In order to override the default, set font.capitalization:

        Button {
            text: "Button"
            font.capitalization: Font.MixedCase
        }
        
        1 Reply Last reply
        5

        • Login

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