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. QQuickView change controls palette
QtWS25 Last Chance

QQuickView change controls palette

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 1.1k Views
  • 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.
  • D Offline
    D Offline
    Dmitry89
    wrote on last edited by
    #1

    I want to change controls color palette without style owerriding? How can I do this

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

      Hi,

      I think you can do this by setting custom QPalette for your Application.

      157

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Dmitry89
        wrote on last edited by
        #3

        @ QGuiApplication app(argc, argv);

        QPalette customPalette;
        customPalette.setColor(QPalette::Window, QColor("red"));
        customPalette.setColor(QPalette::Background, QColor("red"));
        customPalette.setColor(QPalette::WindowText, QColor("red"));
        customPalette.setColor(QPalette::Foreground, QColor("red"));
        customPalette.setColor(QPalette::Base, QColor("red"));
        customPalette.setColor(QPalette::AlternateBase, QColor("red"));
        customPalette.setColor(QPalette::ToolTipBase, QColor("red"));
        customPalette.setColor(QPalette::ToolTipText, QColor("red"));
        customPalette.setColor(QPalette::Text, QColor("red"));
        customPalette.setColor(QPalette::Button, QColor("red"));
        customPalette.setColor(QPalette::ButtonText, QColor("red"));
        customPalette.setColor(QPalette::BrightText, QColor("red"));
        
        app.setPalette(customPalette);@
        

        Doesn't work (

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

          I tried the following which works
          @
          QPalette customPalette(app.palette());
          customPalette.setColor(QPalette::ButtonText, QColor("red"));
          customPalette.setColor(QPalette::WindowText,QColor("yellow"));
          app.setPalette(customPalette);
          @

          and QML
          @
          Button {
          text: "Qt"
          }

          Label {
          text: "Hello world"
          }
          @

          Here the color of the text changes as per the palette but neither QPalette::Window/QPalette::Background/QPalette::Base/QPalette::Button worked for background of button for eg.

          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