[英]Don't allow to maximize/show the application in QML
I have an application in the QML/C++ that shouldn't be able to be maximized/showed by user. 我在QML / C ++中有一个应用程序,它不应该被用户最大化/显示。 It should stay minimized whole time and when it receives a message from a server then it should maximize itself.
它应该始终保持最小化,当它从服务器收到消息时,它应该自己最大化。 Is it possible to do it in the QML?
是否可以在QML中完成? I was looking everywhere and I was not able to find anything similar to my issue.
我到处寻找,我无法找到与我的问题类似的东西。
You can start a window with Window.Hidden
flag and show it when a signal received. 您可以使用
Window.Hidden
标志启动一个窗口,并在收到信号时显示它。 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;
}
}
}
Pay attention - you havn't test this code in Qml Viewer, it start its window anyway although QML window is hidden 注意 - 你没有在Qml Viewer中测试这个代码,它仍然会启动它的窗口,尽管隐藏了QML窗口
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.