Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how to resolve " Error: Cannot assign [undefined] to QString "
Forum Updated to NodeBB v4.3 + New Features

how to resolve " Error: Cannot assign [undefined] to QString "

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 473 Views
  • 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.
  • Q Offline
    Q Offline
    Qt embedded developer
    wrote on last edited by
    #1

    while i am running below code and select files i am getting below error:
    qrc:/main.qml:38: Error: Cannot assign [undefined] to QString

    import QtQuick 2.15
    import QtQuick.Window 2.15
    import QtQuick.Controls 2.5
    import QtQuick.Dialogs 1.3
    
    Window {
        width: 640
        height: 480
        visible: true
        title: qsTr("FileDialog Demo")
    
    
        Column{
            spacing:20
            anchors.centerIn: parent
    
            Button{
                text: "Choose File or folder"
                anchors.horizontalCenter: parent.horizontalCenter
                onClicked: {
                    fileDialogId.open()
                }
            }
            Text {
                id: textID
                text: "Use hasn't chosen yet"
                wrapMode: Text.Wrap
            }
    
            FileDialog{
                id: fileDialogId
                title: "Choose File or Folder"
                // this dialog only allow to select folder
                selectFolder: false
                selectMultiple: true
    
                onAccepted: {
                    textID.text = fileUrls[3]
    
                    for(var i = 0; i < fileUrls.length ; i++){
                        console.log("Value "+ i + "is: "+ fileUrls[i])
                    }
    
                }
    
                onRejected: {
    
                }
            }
    
    
    
        }
    }
    
    
    JonBJ 1 Reply Last reply
    0
    • Q Qt embedded developer

      @JonB yes line 38 is

      textID.text = fileUrls[3]
      

      and its not defined i am selecting files from opened filedialog.

      Actually i want to iterate and print selected file list from file dialog .

      so can anybody help me to print it

      Q Offline
      Q Offline
      Qt embedded developer
      wrote on last edited by
      #4

      @Qt-embedded-developer

      Sorry i have found that my above code is working and its give above error when i select file less than 4

      1 Reply Last reply
      0
      • Q Qt embedded developer

        while i am running below code and select files i am getting below error:
        qrc:/main.qml:38: Error: Cannot assign [undefined] to QString

        import QtQuick 2.15
        import QtQuick.Window 2.15
        import QtQuick.Controls 2.5
        import QtQuick.Dialogs 1.3
        
        Window {
            width: 640
            height: 480
            visible: true
            title: qsTr("FileDialog Demo")
        
        
            Column{
                spacing:20
                anchors.centerIn: parent
        
                Button{
                    text: "Choose File or folder"
                    anchors.horizontalCenter: parent.horizontalCenter
                    onClicked: {
                        fileDialogId.open()
                    }
                }
                Text {
                    id: textID
                    text: "Use hasn't chosen yet"
                    wrapMode: Text.Wrap
                }
        
                FileDialog{
                    id: fileDialogId
                    title: "Choose File or Folder"
                    // this dialog only allow to select folder
                    selectFolder: false
                    selectMultiple: true
        
                    onAccepted: {
                        textID.text = fileUrls[3]
        
                        for(var i = 0; i < fileUrls.length ; i++){
                            console.log("Value "+ i + "is: "+ fileUrls[i])
                        }
        
                    }
        
                    onRejected: {
        
                    }
                }
        
        
        
            }
        }
        
        
        JonBJ Online
        JonBJ Online
        JonB
        wrote on last edited by
        #2

        @Qt-embedded-developer
        Would you like to tell us which is line #38?

        textID.text = fileUrls[3]

        What value does fileUrls[3] have? You're sure it's defined?

        Q 1 Reply Last reply
        0
        • JonBJ JonB

          @Qt-embedded-developer
          Would you like to tell us which is line #38?

          textID.text = fileUrls[3]

          What value does fileUrls[3] have? You're sure it's defined?

          Q Offline
          Q Offline
          Qt embedded developer
          wrote on last edited by Qt embedded developer
          #3

          @JonB yes line 38 is

          textID.text = fileUrls[3]
          

          and its not defined i am selecting files from opened filedialog.

          Actually i want to iterate and print selected file list from file dialog .

          so can anybody help me to print it

          Q 1 Reply Last reply
          0
          • Q Qt embedded developer

            @JonB yes line 38 is

            textID.text = fileUrls[3]
            

            and its not defined i am selecting files from opened filedialog.

            Actually i want to iterate and print selected file list from file dialog .

            so can anybody help me to print it

            Q Offline
            Q Offline
            Qt embedded developer
            wrote on last edited by
            #4

            @Qt-embedded-developer

            Sorry i have found that my above code is working and its give above error when i select file less than 4

            1 Reply Last reply
            0
            • Q Qt embedded developer has marked this topic as solved on

            • Login

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