Shawn, you're right: I can use the QML FileDialog http://doc.qt.io/qt-5/qml-qtquick-dialogs-filedialog.html from my QtQuickControls2 APP without the need to add +widgets. I was confused because doc for Qt.labs FileDialog https://doc.qt.io/qt-5/qml-qt-labs-platform-filedialog.html is mentioning that widgets are needed.
Now this simple FileDialog opens the native iOS Image Picker: FileDialog { folder: shortcuts.pictures } Hint: to open this FileDialog from inside a QQC2 Dialog I had to use an extra QML File. Selecting an Image returns an URL I can use as Image source. Compared this URL with the FilePath I got from C++ QFileInfo and found out why it didn't work before: I had to encode the '?' Path from QML: "file:assets-library://asset/asset.PNG%3Fid=C6E6...77E9&ext=PNG" Path from C++: "assets-library://asset/asset.PNG?id=C6E6...77E9&ext=PNG" To convert QML path to be used with QFile etc: QUrl url(path); path = url.toLocalFile(); To convert C++ path to be displayed as QML Image: path = "file:"+fileInfo.filePath().replace("?","%3F") thx to all helping - now I can go on to develop my QQC2 FilePicker for Android iOS. will be soon available at Github :) ekke Am 27.10.17 um 11:01 schrieb Shawn Rutledge: >> On 26 Oct 2017, at 17:02, ekke <e...@ekkes-corner.org> wrote: >> >> Am 26.10.17 um 16:11 schrieb Shawn Rutledge: >>>> On 26 Oct 2017, at 15:12, ekke <e...@ekkes-corner.org> >>>> wrote: >>>> >>>> Jeffrey, >>>> >>>> thx >>>> >>>> at the moment it's ok for me to use >>>> QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).last() >>>> >>>> Using Objective-C++ Photos framework would give some more comfort, >>>> but wouldn't help to access these Photos from QML >>>> >>> >From QML, the QtQuick.Dialogs FileDialog has special support for getting a >>> >native photo picker: >>> >>> >>> http://doc.qt.io/qt-5/qml-qtquick-dialogs-filedialog.html#folder-prop >> if I understood it right, to use FileDialog I must add >> QT += widgets >> also https://doc.qt.io/qt-5/qml-qt-labs-platform-filedialog.html needs >> widgets and QApplication instead of QGuiApplication. > That’s not necessary on iOS AFAIK. Widget-based dialogs are an option on > desktop systems. The priority is: native dialog if possible (and on iOS, if > you are choosing a picture, we treat the photo picker as a native dialog); if > not, then use a widget dialog if possible (and if it’s not a QApplication, > it’s not possible); if not, then fall back to a plain QML implementation > (DefaultFileDialog.qml). > > (Disclaimer: I haven’t tested that on iOS for quite some time. I hope it > still works. ;-) > >> want to avoid this because my mobile apps are using QtQuickControls2 only > The work of porting over to Controls 2 dialogs is not done yet. > >>>> it seems that there's no way to construct an URL in QML to access files >>>> from assets-library >>>> so probably the best way is to write an ImageProvider to access these >>>> Images from QML >>>> >>> After you choose the photo, you will get a URL which works AFAIK. >> in forum I read that this URL works from C++ but not from QML > Not sure about that… I guess I need to test it again. I thought it was > possible to set an Image.source property to that URL, for example, but we > don’t have much file-reading support in QML otherwise. > _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest