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:
- Download and save uniapp pictures to Android error reporting app
- [How to Solve] Easyclick read text garbled
- [Android] method of removing title bar and using request window feature (Window.FEATURE_ NO_ Title); why does it fail
- Go declares that the local variable does not use command line arguments. Main. Go: 4:6: a declared but not used
- Error (active) e1696 cannot open source file “errno.H” rpgworld problems encountered in installing visual studio 2017
- [Solved] VScode Error: build constraints exclude all Go files in syscall\js
- [Solved] Interface automation test: JSON parse error
- [Solved] ViewBinding Error: java.lang.ClassCastException: android.widget.RelativeLayout cannot be
- How to Solve Error: Type mismatch: cannot convert from Object to Car
- NLTK Error: [Error:11004] getaddrinfo failed [How to Solve]
- Opencv c++ Read Video Error: capture.isOpened() Return false
- Taro Use React Hooks Error: TypeError: Object(…) is not a function
- How to Solve error C2039: “to_ String “: not a member of” STD “
- R: Data frame index error “unexpected token”
- Tensorflow C++:You must define TF_LIB_GTL_ALIGNED_CHAR_ARRAY for your compiler
- Filezilla Error: You appear to be behind a NAT router. Please configure the passive mode settings and …
- How to Solve Cocos creator label text is too many error
- GO Exception Runnerw.exe: CreateProcess failed with error 21
- The browser is compatible with IE11 “ReferenceError: ‘Promise’ is not defined” “ReferenceError: ‘Promise’ is not defined”
- Celery Error: Did you remember to import the module containing this task?