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. QGuiApplication palette not set to ApplicationWindow
Forum Updated to NodeBB v4.3 + New Features

QGuiApplication palette not set to ApplicationWindow

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

    Re: QQuickView change controls palette

    It looks like the ApplicationWindow is not affected by the QGuiApplication's palette values.
    My environment is Qt 5.12.5 on Linux. I started over with an empty project to make sure of my results.

    main.cpp:

        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    
        QGuiApplication app(argc, argv);
    
        QPalette palette = QGuiApplication::palette();
        QPalette newPalette(palette);
        newPalette.setColor(QPalette::ColorRole::WindowText, QColor("#00FF00"));
        QGuiApplication::setPalette(newPalette);
    

    main.qml:

    ApplicationWindow {
        visible: true
        width: 640
        height: 480
    
        Component.onCompleted: {
            console.log("Text color : " + palette.windowText)
        }
    
        Text {
            text : "hello"
        }
    }
    

    Logs "Text color : #26282a"
    What am I missing if we refer to the documentation?

    1 Reply Last reply
    0
    • SeeLookS Offline
      SeeLookS Offline
      SeeLook
      wrote on last edited by SeeLook
      #2

      Hi @jean_b

      Probably You have to specify a color group which the change affects:

      newPalette.setColor(QPalette::Active, QPalette::WindowText, QColor("#00FF00"));
      

      It works for me.

      1 Reply Last reply
      0
      • I Offline
        I Offline
        igh.de
        wrote on last edited by
        #3

        It only works if you use the Fusion-style. The documentation states: The Fusion style uses the standard system palettes to provide colors that match the desktop environment.

        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