Im my app based on QML
I use Camera
and CameraCapture
to capture an image from the camera. After it was captured I want to store captured image in application data folder with CameraCapture.captureToLocation()
. But I have no idea how to get path to this folder. So my question - how can I get path to application folder wit write permissions? Is there way in Qt to get it? It should be system specified folder, I guess. For example in Android it should be /data/data/AppName. As I see LocalStorage creates its files in some similar place.
相关问题
- Sorting 3 numbers without branching [closed]
- QML: Cannot read property 'xxx' of undefin
- QML: Cannot read property 'xxx' of undefin
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
相关文章
- ubuntu20.4中c#通过c++库调用python脚本
- Qt槽函数自动执行多遍
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
You can use
QStandardPaths
to specify a writable location :Here
QStandardPaths::GenericDataLocation
returns a directory location where persistent data shared across applications can be stored and it is never empty.It's also possible use
QStandardPaths::ApplicationsLocation
or many others which could be found here. You can implement a function in C++ side and use it in your QML to get the standard location./data/data/AppName
is not mapped in QStandardPaths, but I think it would be better to use this one:or this one in earlier versions:
These will be set to
DataLocation "<APPROOT>/files", "<USER>/<APPNAME>/files"
underneath on Android.But note that from 5.4 on, the latter is deprecated as documented. You can set it then as follows:
So, you would write something like this:
Note: Please do not use
QStandardPaths::ApplicationsLocation
for this purpose since that is the non-dedicated location. In addition, it is even unsupported on Android:If you want to share the image across applications, you would need to use this with minor adjustment to the code above. While I think you wanted the one above, it is a bit unclear which one you wanted, so I am mentioning both:
This is set to
GenericDataLocation "<USER>"
on Android. The exact mappings are mentioned in the class documentation, you just need to scroll down to the tables. I cannot give direct URL as there is no permalink to that section. You can check yourself, too, which fits the best.