Dialogs in Qt 6 using CMake
-
@qcoderpro
you must callopen()
on the dialog at some point. its not visible by default.
https://doc.qt.io/qt-5/qml-qtquick-controls2-popup.html#details
(Dialog inherits Popup) -
Or simply,
visible: true
.
Thank you for your brief and to the point reply. -
Now if I want to add a simple
FileDialog
like this:FileDialog { id: fileDialog folder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation) }
The compiler gives me the error: FileDialog is not a type
So I needimport Qt.labs.platform
. When I add that, this time I get an error about the Dialog!
Dialog is an abstract base classSeemingly there can't be possible to have both the Dialog and FileDialog elements together in a project!
-
@qcoderpro said in Dialogs in Qt 6 using CMake:
The compiler gives me the error: FileDialog is not a type
So I need import Qt.labs.platform.Dialog in FileDialog is in QtQuick.Dialogs import though: https://doc.qt.io/qt-6/qml-qtquick-dialogs-filedialog.html . Can you try this?
-
Apparently Qt6's elements are just being updated. Look the first example in that link where there's a
folder
property. Do you see it in on the list declared asFileDialog
properties!? The Qt Creator's compiler also rises an error regarding that. -
The 2 imports are clashing because they both contain a
Dialog
type. Use an "import as" to prevent this:import QtQuick import QtQuick.Controls import Qt.labs.platform as Labs Window { // ... Dialog { // ... } Labs.FileDialog { // ... } }
-
The 2 imports are clashing because they both contain a Dialog type. Use an "import as" to prevent this:
I'm glad to know that how you found this.
Still the compiler has an issue with the
folder
line!
ReferenceError: StandardPaths is not definedDialog { id: dialog x: 200 title: "test" visible: true standardButtons: Dialog.Ok | Dialog.Cancel } Labs.FileDialog { id: fileDialog folder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation) }
-
@qcoderpro said in Dialogs in Qt 6 using CMake:
I'm glad to know that how you found this.