3

I would like to select an image from existing files in an app written in Qt 5.9 (using Qt Quick and some c++). I tried to use FileDialog from QML (official example here) but when I run it in the emulator, it looks like this: funny open dialog

I did read this blogpost http://amin-ahmadi.com/2015/12/08/how-to-open-android-image-gallery-in-qt/ which explains how to use native code for gallery chooser though I am wondering if meanwhile Qt progressed to make such task readily available in a more straightforward manner.

EDIT: A hint is that FileDialog.shortcut documented here says:

The directory containing the user's pictures or photos. It is always a kind of file: URL; but on some platforms, it will be specialized, such that the FileDialog will be realized as a gallery browser dialog.

eudoxos
  • 18,545
  • 10
  • 61
  • 110
  • Have you tried http://doc.qt.io/qt-5/qml-qtquick-dialogs-filedialog.html – m7913d Dec 04 '17 at 14:31
  • @m7913d That's the one I used, I only liked the example page rather than the documentation, I will add the link to the question. – eudoxos Dec 04 '17 at 16:17
  • But what we see here, correct me if I'm wrong, are the buttons created in the example and not those of the native FileDialog. Have you tried running the minimal example in the [`FileDialog` Detailed Description](http://doc.qt.io/qt-5/qml-qtquick-dialogs-filedialog.html#details)? – m7913d Dec 04 '17 at 17:22
  • you can use or rework this dialog https://github.com/dobokirisame/qml-filedialog – Andrey Semenov Dec 04 '17 at 20:06
  • @AndreySemenov: thanks, looks very nice! I will still leave the question open just in case there is, at some point, an easy way to call up the native picker. – eudoxos Dec 06 '17 at 09:24
  • you can simply do by this post: https://stackoverflow.com/questions/42885655/how-to-open-ios-gallery-in-qt it is work on android and ios. – Farshad Bayat Mar 09 '18 at 08:43

2 Answers2

1

Better late than never:

Your application probably uses high DPI scaling, which automatically scales the QtQuick.Controls 2 on displays with higher DPI. In main.cpp:

QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

Basically the px sizes in your app don't represent physical pixels anymore. Some (older) Qt components, one of those is the FileDialog, don't work as expected on that setting. Removing it should fix your problem, but will probably affect the visual appearance of you app. More Info: https://blog.qt.io/blog/2016/01/26/high-dpi-support-in-qt-5-6/

You could try to build your own FileDialog with the FolderListModel: https://doc.qt.io/qt-5/qml-qt-labs-folderlistmodel-folderlistmodel.html

JaTe
  • 21
  • 4
0

There is also a QML component available to display and select single or multiple images. You can find more info here: https://felgo.com/updates/release-3-2-0-qt-5-12-3-subscriptions

You can also test it right on your mobile phone: https://felgo.com/web-editor/?snippet=77c7ad94

Alex Huber
  • 503
  • 3
  • 11