Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

[Solved] How to reload QML file with ApplicationWindow object?

$
0
0
Hi everybody! I’ve found solution of my problem. But I not sure what this is a best way to solving the problem. If somebody found a simple way please tell me. Thanks. The solution: I’ve created the JS script like this: /** The global component for save a centeral widget.*/ var centeralWidget = null;     /** Create a center widget with show data from MDL file.  *  @param qmlFile The full path to centeralWidget QML file.  *  @param parent The parent object on which centeral widget will be shown.  *  @author Andrew Shapovalov.*/ function createCenteralWidget(qmlFile, parent) {     if(centeralWidget !== null)     {         centeralWidget.opacity = 0.0;         centeralWidget.destroy();     }       var tmp = Qt.createComponent(qmlFile);     var options = {"id": "widget",         "anchors": {"top": parent.bottom},         "width": parent.width,         "height": parent.height};     centeralWidget = tmp.createObject(parent, options);       if(centeralWidget === null)     {         return false;     }       return true; } And Using it in my QML code:     MdlManager {         id: logManager           signal reload(string logFile);           objectName: "logManager"         onMdlLogParserDidFinished: {             if(!QmlCreator.createCenteralWidget("qrc:/qml/MdlViewer/CentralWidget.qml", center))             {                 console.debug("ERROR: Can't create a QML object.");             }         }     } Now, when user choose file the application will recreating the central object and reload content.

Viewing all articles
Browse latest Browse all 4972

Trending Articles