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. Custom Button is not styled by the Material theme

Custom Button is not styled by the Material theme

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 3 Posters 291 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.
  • F Offline
    F Offline
    Florin1
    wrote on last edited by
    #1

    Hello,

    I need to create a custom button, which uses as a root element a regular button from QtQuick.Controls 2. Inside this new component, called ButtonWithHelp.qml, I've added some additional functionality.
    Something along the lines:

    import QtQuick 2.12
    import QtQuick.Controls 2.12
    
    Button {
        id: customControl
        contentItem: //code here
        background: //some more code here
    }
    

    Everything works as expected, except the styling. In main.cpp I set the style by doing

    QQuickStyle::setStyle("Material");
    

    which modifies all the other buttons except when using ButtonWithHelp.

    I do not want to manually define the colors inside the component as I hope to have a general style which should be applicable at runtime.

    Does anyone know what needs to be done?

    Thank you.
    Florin

    1 Reply Last reply
    0
    • N Offline
      N Offline
      nullbuil7
      wrote on last edited by
      #2

      which operating system are you using?
      if it's win10 you can only use "windowVisa" , "Windows" and "Fusion"

      1 Reply Last reply
      -1
      • GrecKoG Offline
        GrecKoG Offline
        GrecKo
        Qt Champions 2018
        wrote on last edited by
        #3

        @nullbuil7 this question is about Qt Quick, not QWidgets. The styles are not dependent on the platform.

        Button {
           id: customControl
           contentItem: //code here
           background: //some more code here
        }
        

        Qt Quick Controls styles use their own contentItem and background to style a control, you are overriding them here.

        What do you want to actually achieve by customysing the controls?

        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