How to create QtObject inside a js file?

191
1
03-19-2021 06:07 AM
x_d
by
New Contributor III

So I need to make a directory if it's not exist by using QtObject. This code works fine inside a qml file but I need to create and use this code inside a javaScript file. How to do it?

QtObject {
    id: internal
     property url folderUrl: "image";
}

FileFolder { 
    id: fileFolder
    url: "assets/media_images"//internal.folderUrl
    Component.onCompleted: {
        if (!fileFolder.exists) {
            fileFolder.makeFolder(internal.folderUrl);
        }
    }
}

  

Tags (3)
0 Kudos
1 Reply
ErwinSoekianto
Esri Regular Contributor

@x_d 

 

I think this documentation from Qt will help you, https://doc.qt.io/qt-5/qtqml-javascript-dynamicobjectcreation.html 

 

Erwin. 

0 Kudos