Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. add avatar stackview with filedialog
Qt 6.12 LTS is out! See what's new in the release blog

add avatar stackview with filedialog

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 534 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    filipdns
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt
    • Unsolved