QtQuick Material in secondary Window



  • Hello, i'm new at QML and want to create a domestic alarm. I succesfully created a window with buttons and images with a Dark theme, but when i want to open a new window i can't set the same theme. I tried putting the code in a different .qml and in the same .qml. My code is like this:

    @
    import QtQuick 2.7
    import QtQuick.Controls 2.0
    import QtQuick.Controls.Material 2.0
    import QtQuick.Layouts 1.3
    import QtQuick.Window 2.0

    ApplicationWindow {
    visible: true
    width: 640
    height: 480
    title: qsTr("Smart Home")
    Material.theme: Material.Dark
    Material.accent: "#004D40"
    
    Image {
               ......
    }
    Rectangle {    
        ...
        AnimatedImage {
            ....
        }
    
        MouseArea {
            .....
        }
    }
    
    Window {
        id: ventanaprueba
        visible: true
        Material.theme: Material.Dark
        Material.accent: Material.DeepOrange
    }
    

    }
    @

    The window "ventanaprueba" opens but all white, when it should have a black background. I tried adding in the main.cpp file #include <QQuickStyle> and QQickStyle::setStyle("Material"); but didn't change anything.
    Can someone please help me? Thanks in advance



  • Window isn't aware of the QQuickStyle, if you want to have a style window use ApplicationWindow.



  • @GrecKo That was it. Thank you very much!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.