How to change qml's SystemPalette globally in linux

187 Views Asked by At

I'm using systemPalette (Qt5.15) in several qml-based applications in Linux, I need one of these applications to change systemPalette of qml system-wide (globally) so that other applications can detect this change at runtime.

what I need is similar to what happens in KDE, for example, I have the following qml code:

import QtQuick 2.15
import QtQuick.Window 2.15
Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")

    SystemPalette {
        id: palette
        colorGroup: SystemPalette.Active
    }

    Rectangle{
        anchors.centerIn: parent
        width: 200
        height: width
        color: palette.base

    }
}

when I run the above code in my KDE plasma, if I change the system's theme from breeze to breeze-dark, the rectangle's color will change at runtime, I can even select a custom color in Appearance->globalTheme->colors. In my case, regardless of Linux's distro, my application needs to change systemPalette globally and set its custom values for colors, how can I do that? where does qt read those color values from? (for systemPallete)

Thanks.

P.S: I can create my own style/plugin for qt and set different colors in my custom style, but still I have no idea how to change OS style globally so that all applications can detect this at runtime.

0

There are 0 best solutions below