how to resolve " Error: Cannot assign [undefined] to QString "
-
while i am running below code and select files i am getting below error:
qrc:/main.qml:38: Error: Cannot assign [undefined] to QStringimport 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: { } } } } -
@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
Sorry i have found that my above code is working and its give above error when i select file less than 4
-
while i am running below code and select files i am getting below error:
qrc:/main.qml:38: Error: Cannot assign [undefined] to QStringimport 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: { } } } }@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? -
@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?@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
-
@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
Sorry i have found that my above code is working and its give above error when i select file less than 4
-
Q Qt embedded developer has marked this topic as solved on