Qt6.2.2 MessageDialog and FileDialog QML Type issue
-
Hi. I'm using Qt 6.2 and I want to use FileDialog and MessageDialog from QtQuick.Dialogs.
But this docs says the MessageDialog is not included in QtQuick.Dialogs of Qt 6.2.
Although I tried to use the MessageDialog in QML, the compiler said that I needed to include Qt Widgets module to my project. So I did it, and it worked. So now I can use 'FileDialog' and 'MessageDialog' both in my project using Qt 6.2.
However, after I included the 'Qt Widgets' module in my project, I couldn't use the FileDialog's currentFile property, with following error: "ReferenceError: selectedFile is not defined" I had used it before including Qt Widgets. Anyone know why?Target platform: Windows 10
Using IDE: Visual Studio 2019 with Qt extension
Using Qt versions: 6.2.2_msvc2019_62
Using Modules: core, gui, widgets, qml, quickwidgets, quick, quickcontrols2code
/// main.cpp #include <QApplication> // ... int main(int argc, char** argv) { QApplication app(argc, argv); // .. some codes.. return app.exec(); }
/// qml import QtQuick 2.9 import QtQuick.Controls 2.12 import QtQuick.Window 2.15 import QtQuick.Dialogs import Qt.labs.platform Window { // some codes MessageDialog { // some codes } FileDialog { fileMode: FileDialog.SaveFile // works defaultSuffix: "avi" // works nameFilters: [ "avi (*.avi)" ] // works function saveopen() { currentFIle = new Date().toLocaleString(Qt.locale(), "yyMMddHHmmss") open() // works } onAccepted: { let fullLen = selectedFile.length // not defined 'selectedFile' var name = selectedFile.toString().substring(8, fullLen - 4) mycppbackend.method(name) } } }
-
I need to use Qt.labs.platform, rather QtQuick.Dialogs module because former contains MessageDialog and FileDialog both but latter is not. So I removeed "import QtQuick.Dialogs" above code. However, FileDialog from Qt.labs.platform does not contain "selectedFile" property, so I switch it to "currentFile" and it works.