Don't let the app maximize / show in QML

I have an application in QML / C ++ that should not be maximized / shown by the user. It must stay minimized all the time and when it receives a message from the server then it must maximize itself. Can this be done in QML? I've searched everywhere and I couldn't find anything similar to my problem.

+3


source to share


1 answer


You can launch a window with a flag Window.Hidden

and show it when receiving a signal. Simple example:

import QtQuick 2.3
import QtQuick.Window 2.2

Window {
    id:  mainWindow
    visibility: Window.Hidden
    width: 400
    height: 300

    Text {
        text: qsTr("Hello World")
        anchors.centerIn: parent
    }

        Timer {
            id: timer
            interval: 5000
            onTriggered: {
                console.log("signal received");
                mainWindow.visibility = Window.Maximized
            }
        }
        Component.onCompleted: {
            console.log("window created");
            timer.running = true;
        }
    }
}

      



Please note - you are not testing this code in the Qml Viewer, it still launches its window, although the QML window is hidden

+2


source







All Articles