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. [Solved] QPalette and SystemPalette

[Solved] QPalette and SystemPalette

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.0k 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.
  • S Offline
    S Offline
    svg_18
    wrote on last edited by
    #1

    Hello,

    First of all, I am new to Qt/QML, so sorry if my post is confusing but I'm confused myself. I'll try to be specific.
    I have an app that uses C++/QML integration. I want my visual elements to have a consistent look, so I need to use SystemPalette. For example, if I have in qml:

    @SystemPalette {id: myPalette; colorGroup: SystemPalette.Active }@

    then for some text element I can do:

    @Text { id: myText; color: myPalette.text }@

    However, the default colors that I get from SystemPalette don't suit my needs.
    I read that you can set QPalette colors in the C++ code and then set the custom palette as app palette:

    @QPalette customPalette = myApp->palette();
    customPalette.setColor(QPalette::WindowText, QColor("red"));
    myApp->setPalette(customPalette);@

    but this had no effect for me and I don't see what I am missing here.

    My question: Is there a way to change the default SystemPalette colors? Or alternatively, how do I use my customPalette from qml?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jens
      wrote on last edited by
      #2

      I haven't tried it but you are using the "WindowText" role on the C++ side and the "Text" role on the qml side. Perhaps you can simply change your C++ code to:
      @customPalette.setColor(QPalette::Text, QColor("red"));@

      1 Reply Last reply
      0
      • S Offline
        S Offline
        svg_18
        wrote on last edited by
        #3

        I knew it was something that simple. Thanks for pointing it out!

        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