add avatar stackview with filedialog
Unsolved
QML and Qt Quick
-
Hello, I did project using stackview and I'm happy about the result.
In my first page I have 2 picture and selected one of them call the second corresponding.
here the code:ListView { id: listView2 anchors.fill: parent topMargin: 10 leftMargin: 10 bottomMargin: 10 rightMargin: 5 spacing: 20 model: ["F-GMGB","F-GMLT"] delegate: ItemDelegate { width: avatar2.implicitWidth height: avatar2.implicitHeight rightPadding: avatar2.implicitWidth onClicked: stackView.push("qrc:/presentation.qml", { inConversationWith: modelData }) Image { id: avatar2 source: "qrc:/images/" + modelData.replace(" ", "_") + ".png" } } }
as you see, I have use 2 "model" named F-GMGB and F-GMLT.
Now I want to be able to add an other one to be able to update without recompile my project.
I try that:
ListView { id: listView2 anchors.fill: parent topMargin: 10 leftMargin: 10 bottomMargin: 10 rightMargin: 5 spacing: 20 model: ["F-GMGB","F-GMLT",filename] delegate: ItemDelegate { width: avatar2.implicitWidth height: avatar2.implicitHeight rightPadding: avatar2.implicitWidth onClicked: stackView.push("qrc:/presentation.qml", { inConversationWith: modelData }) Image { id: avatar2 source: "qrc:/images/" + modelData.replace(" ", "_") + ".png" } } } } Button { id: dialogButton text: "new" onClicked: { fileDialog.open() } } function basename(str) { return (str.slice(str.lastIndexOf("/")+1)) } FileDialog { id: fileDialog title: "Please choose a file" folder: shortcuts.home nameFilters: [ "Image files (*.png)"] onAccepted: { var res1 = basename(fileUrl.toString()) var res2 = res1.split(".") var filename = res2[0]; console.log(filename) fileDialog.close() } } }
so the filename is corrected extract but how can I implement the corresponding qml page and the qml.qrc to have it in memory on next opening?
Thank you for your help