Unsolved What to import for Qml File Dialog
-
I'm currently trying to access a QML File Dialog object from a C++ QQuickItem, but I can't figure out what to cast it to or where to import from. The doc page at http://doc.qt.io/qt-5/qml-qtquick-dialogs-filedialog.html doesn't give a C++ integration import, just the import for QML files. Does anyone know what the import is, or where I can find it in the future?
-
@IanHowell
not all QML components (actually very little do) also export the C++ API.
Components implemented outside QtQuick (the ones implemented with plugins) actually never do IIRC -
Alright, so should I create 'controller components' to make use of them? Like:
FileDialogController { FileDialog { visible: fileDialogController.visible } }
Where the FileDialogController has a boolean Q_PROPERTY visible? Would this be good practice (not this example in specific but as a general trend)?
-
@IanHowell
i actually don't even know what you want to achieve exactly -
I basically want to be able to open the file dialog from a C++ qquickitem subclass.
-
@IanHowell
so yes if you like your approach go with it.
Alternatively you can also get a QQuickItem* (by defining a Q_PROPERTY or via a Q_INVOKABLE method) to your "controller" class.In there you should be able to call methods on the item and access it's properties even without knowing it's exact type:
QQuickItem* item = ... // call method QMetaObject::invokeMethod(item, "methodName", Qt::AutoConnection); // read property QVariant v = QQmlProperty::read(item, "propertyName");