I started working on QT/QML, PyQt Desktop Application. I have some basic knowledge of Qt/QML and all.
I'm trying to modify one Desktop Application already Exists.
Here is I've add one Button in Main Window of Application which Open another Window.
main.qml
Button {
text: "Open Window"
Loader{ id: pageLoader }
onClicked: {
console.log("Clicked")
pageLoader.source = "testing.qml"
}
}
testing.qml
import QtQuick 2.2
import QtQuick.Window 2.2
Window {
id: win1
width: 1000;
height: 1000;
visible: true;
visibility: "Maximized"
color: "#363636";
title: "First Window";
Text {
anchors.centerIn: parent
text: "Page 1"
}
MouseArea{
anchors.fill: parent;
onClicked: pageLoader.source="";
}
}
When I clicked on Button, New Window is open Successfully. But When I closed new Window and Tried to reopen, It'll not open. It just print "Clicked".
答案 0 :(得分:0)
Your problem is, that you clear the Loader
s source, only when you close the window by clicking on the MouseArea
it contains. If you close it with the x
-button you don't clear it, so the loader stays active and the source stays the same.
To solve this, you can either make sure, the source changes, when ever you click the open-Button
, by having
onClicked: {
pageLoader.source = "" // Clearing first
pageLoader.source = "testing.qml" // Setting again
}
or by using the Window
s closing()
-signal
onClosing: pageLoader.source = ""