When we want to use the file dialog box in the interface, we can use the FileDialog component with the following code:
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Dialogs 1.3
Window {
visible: true
width: 640
height: 480
title: qsTr("")
Button {
id:openFile
text: qsTr("Open the Files")
backgroundDefaultColor: "#5A6268"
onClicked: {
fileDialog.open()
}
}
FileDialog {
id: fileDialog
title: qsTr("Please choose a file")
nameFilters: ["Photo Files", "Image Files (*.jpg *.png *.gif *.bmp *.ico)", "*.*"]
onAccepted: {
_filePath.text = String(fileUrl)
var filepath = new String(fileUrl)
}
}
}
Error Message:
file:///D:/Qt/Qt5.12.6/5.12.6/msvc2017_64/qml/QtQuick/Dialogs/DefaultFileDialog.qml:102:33: QML Settings: Failed to initialize QSettings instance. Status code is: 1 file:///D:/Qt/Qt5.12.6/5.12.6/msvc2017_64/qml/QtQuick/Dialogs/DefaultFileDialog.qml:102:33: QML Settings: The following application identifiers have not been set: QVector("organizationName", "organizationDomain")
Solution:
Add a line of code to the main function of main.cpp.
QCoreApplication::setOrganizationName("appName.org");//appName.org can be set at will
Read More:
- Filezilla Error: You appear to be behind a NAT router. Please configure the passive mode settings and …
- How to Solve Error: Type mismatch: cannot convert from Object to Car
- How to Solve error C2039: “to_ String “: not a member of” STD “
- How to Solve OpenCV CVUI Error: LINK2019
- How to Solve Error: could not list the contents of folder
- How to Solve UE5 Compile Error: Error MSB3073
- How to Solve Jquery 1.9 $.browser Error
- How to Solve Kotlin unresolved reference error
- How to Solve Error: Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]
- How to Solve ImportError: cannot import name gof
- How to Solve Error: Heartbeating to master:7182 failed.
- How to Solve ModuleNotFoundError: No module named ‘_bz2‘
- How to Solve Import antd Error: Module build failed
- Internalerror: GPU sync failed error (How to Solve)
- How to Solve Arxiv Upload with PDFLatex Error
- How to Solve Pydicom Read Dicom File Error: OSError
- How to Solve Cocos creator label text is too many error
- How to Solve Android Error: gps requires ACCESS_FINE_LOCATION
- MAC: How to Solve VirtualBox cannot open Issues