Issues with using object.destroy()
-
Hello,
I am trying to implement a Reset button such that when the user clicks 'Reset', I dynamically create a QML file using the method shown here:
"Dynamic Object Management":http://qt-project.org/doc/qt-4.8/qdeclarativedynamicobjects.html
This object I make is a simple confirmation box that says: "Are you sure?" and has two buttons Yes or No.
The Yes Button works fine, but when I click No, I want to remove the box and so I run container.destroy(). The following is the QML file I create for the confirmation box@import QtQuick 2.0
import QtQuick.Controls 1.0
import "../SetUp/SetUp.js" as SetUpRectangle {
id: container
width: parent.width0.1; height: parent.height0.1
anchors.centerIn: parent
color: "black"; radius: 5;
Column {
anchors.centerIn: parent
id: col
spacing: 5
Item {
width: ask.width; height: ask.height
Text {
id: ask
text: "Are you sure?"
color: "white"
font.pixelSize: container.height*0.25
}
}
Item {
width: row.width; height: row.height
Row {
id: row
spacing: 2
Button {
text: "Yes"
onClicked: {
SetUp.pageNum = 1;
SetUp.menuOn = 0;
SetUp.createSpriteObjects("SetUp.qml")} } Button { text: "No" onClicked: { SetUp.menuOn = 0; container.destroy() } } } } }
}
@After selecting No, I can't click any other buttons on my screen to enable other menu options. I can't even click the Reset Button anymore....
Can someone explain why this happens and if I can fix it? -
Does the console output something? Because since i remember one component can't destroy itself.
-
yes it does, if i change the No button to:
@Button {
text: "No"
onClicked: {
SetUp.menuOn = 0;
container.destroy()
console.log("die")
}
}@the console outputs 'die' and the object is destroyed, but I cant click the reset button which created the object the first time
-
also, the reset button which creates this confirmation box is the only thing I can't click to elicit a 'console.log("fsdafa")' line after I click 'No' and destroy the box. The other menu options still print to the console