how to recall a destroyed element in Qml?
Unsolved
QML and Qt Quick
-
here is a button which will destroy an item upon clicked but when the item is recalled it's showing me a blank page. is there any method to recall that item again after destroying?
Button{ id: backButton5 width: menuRow5.width*(59/1920) height: menuRow5.height onClicked: { mappingWidgetId.visible=!mappingWidgetId.visible treebuttonUnmappedIn.destroy() }
UnmappedTreeViewButtonPressed { id: treebuttonUnmappedIn anchors.left: parent.left anchors.top: parent.top }
RoundButton { id:viewUnmappedSettingsButton height:mappingWidget.height*(33/1200) width:mappingWidget.width*(265/1920) onClicked: { treebuttonUnmappedIn.visible = true }}
UnmappedTreeViewButtonPressed.qml
import QtQuick 2.15 import QtQuick.Window 2.15 import QtQuick.Controls 2.15 import QtQuick.Dialogs 1.3 import QtQuick.Layouts 1.15 Rectangle{ id: unmappedTreeId height:1000 width: 1000 anchors.leftMargin:350 anchors.topMargin: 200 color: "white" visible: false }
-
@Sanyam said in how to recall a destroyed element in Qml?:
treebuttonUnmappedIn.destroy()
I cannot even find where "destroy" function/signal is documented. Anything created by QML is managed by QML. If you want to hide something then make it invisible by setting visible to false. If you want to create and destroy things then use Loaders, Repeaters or various Views and a model. Stay far away from using hands on memory management type stuff in QML. I would consider that an anti-pattern in QML.