Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Newbie Question: Display fileURLs from FileDialog - getting error from delegate
Forum Updated to NodeBB v4.3 + New Features

Newbie Question: Display fileURLs from FileDialog - getting error from delegate

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 697 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.
  • C Offline
    C Offline
    cemck
    wrote on last edited by
    #1

    Hi I'm a QT Newbie, UI Newbie, liking QT Quick but having problem displaying data retrieved with FileDialog. I get an error message from my cfilesDelegate.

    console output:
    You chose: file:///Users/cmckenzie/Desktop/Beatles/(The Beatles) - Taxman.mp3
    qrc:/content/Layouts.qml:86: ReferenceError: url is not defined (repeated 9 times)

    I’m using Qt Quick 2 in QtCreator 2.7.2 with Qt 5.1.0.

    FileDialog {
    id: fileDialog
    nameFilters: [ "Music files (*.wav *.mp3)" ]
    title: "Please choose a folder or file"
    onAccepted: {
    console.log("You chose: " + fileDialog.fileUrl)

                cfilesModel.append({"url":fileDialog.fileUrl.string})
    
            }
            onRejected: {
                console.log("Canceled")
            }
    
        }
    
    Action {
        id: openAction
        text: "&Open"
        shortcut: "Ctrl+O"
        iconSource: "images/document-open.png"
        onTriggered: fileDialog.open()
        tooltip: "Open an image"
    }
    
    ListModel {
        id: cfilesModel
    }
    

    Here's where I try to display
    GroupBox {
    id: gridBox
    title: "Folders or Files in Collection"
    Layout.fillWidth: true

         TableView{
             id: cfilesView
            model:cfilesModel
            anchors.fill: parent
            rowDelegate: cfilesDelegate
            TableViewColumn {
                role: "url"
                title: "Url"
                width: 240
                 }
    

    Component {
    id: cfilesDelegate
    Row {
    Text { text: url }
    }
    }

    Thanks for assistance,

    Clara McKenzie

    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 Extensions
    • Unsolved