Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QML Loader ... How to unload or delete a qml page loaded on to Loader element

I have loaded MyItem.qml as a source component onto Loader element. Now i want to remove or unload that page from Loader element. I tried to set source : "" & sourceComponent : "" , also sourceComponent : "undefined". But it did not work

like image 860
Bupa Avatar asked Feb 15 '17 15:02

Bupa


Video Answer


2 Answers

You should set sourceComponent = undefined or source = "". Usually, I use this code:

Loader{
    id: loader
    function show(component) {
        sourceComponent = component;
    }
    function hide(){
        sourceComponent = undefined;
    }
}
like image 150
albertTaberner Avatar answered Sep 24 '22 02:09

albertTaberner


You can just set the active property to false for unload or true (default) for loading.

like image 34
Kevin Krammer Avatar answered Sep 27 '22 02:09

Kevin Krammer