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. QtQuick Controls 2 Style: Material.background and Universal.background NOT working
Forum Updated to NodeBB v4.3 + New Features

QtQuick Controls 2 Style: Material.background and Universal.background NOT working

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 1 Posters 376 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
    djdan
    wrote on last edited by
    #1

    Hello everyone!
    I want to change background of Universal style, so buttons color would match the other stuff, but background property does not working :/ Other properties (accent, foreground and theme) work as it should. Also on the default style I can change colors of my buttons using palette.button: "#color", but I want to use Universal style on which palette.button: "#color" also does not working

    My code:

    main.qml:

    import QtQuick 2.13
    import QtQuick.Window 2.13
    import QtQuick.Controls.Universal 2.0
    import QtQuick.Controls 2.13
    
    Window {
        width: 640
        height: 480
        visible: true
        color: "#786969"
        title: qsTr("Hello World")
    
    
        Universal.accent: "Black"               //ok
        Universal.background: "Blue"            //NOT OK
        Universal.foreground: "Yellow"          //ok
        Universal.theme: Universal.Dark         //ok
    
        Button {
            id: button
            x: 270
            y: 138
            text: qsTr("Button")
        }
    
        CheckBox {
            id: checkBox
            x: 272
            y: 200
            text: qsTr("Check Box")
        }
    
        Slider {
            id: slider
            x: 220
            y: 264
            value: 0.5
        }
    
        Switch {
            id: switch1
            x: 267
            y: 334
            text: qsTr("Switch")
        }
    }
    

    main.py:

    import sys
    import os
    
    from PySide2.QtGui import QGuiApplication
    from PySide2.QtQml import QQmlApplicationEngine
    from PySide2.QtQuickControls2 import QQuickStyle
    
    
    if __name__ == "__main__":
        app = QGuiApplication(sys.argv)
        QQuickStyle.setStyle("Universal")
        engine = QQmlApplicationEngine()
        engine.load(os.path.join(os.path.dirname(__file__), "main.qml"))
    
        if not engine.rootObjects():
            sys.exit(-1)
        sys.exit(app.exec_())
    

    Thank you everyone for help! :D

    1 Reply Last reply
    0
    • D Offline
      D Offline
      djdan
      wrote on last edited by
      #2

      I'm sending also printscreen:

      ed4435dc-2d4c-4d58-be1d-3763bb310f11-image.png

      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