Home > front end >  [Edited]Teach me how to get 'QtAndroid.h' header file
[Edited]Teach me how to get 'QtAndroid.h' header file

Time:01-07

now I'm developing an android app using qt creator.

I want to make a mp3 player app

so I need file permission to access mp3 files.

on Internet, some guys said 'you have to use QtAndroid.h header file'

So, I tried, but I can't include 'QtAndroid.h' header file, There is no 'QtAndroid.h' header file.

How can I get this header file?

There is document about QtAndroid header file. https://doc.qt.io/qt-5/qtandroid.html

My Qt version is 6.4(maybe) but there is no QtAndroid header file in my environment.

When I installed qt libraries, I checked android items.

please give me a help

CodePudding user response:

I solved the probelm.

The QtAndroid.h file has been replaced with qandroidextras_p.h on 6.2

https://doc.qt.io/qt-6/qtandroidprivate.html#requestPermission-1

we have to include header file, like this

#include <6.4.2(qt version)/QtCore/private/qandroidextras_p.h> 

But when I include this header file, on Error message, it can't find the included header file in the qandroidextras_p.h file. This part seems to need to edit the included header file path of the qandroidextras_p.h file.

CodePudding user response:

I succeeded in getting file permissions.

There is header file

#include <QtCore/private/qandroidextras_p.h>

I have to copy the private(QtCore/6.4.2/QtCore/[private]/qandroidextras_p.h) folder to first QtCore folder.

if you don't copy this folder, compiler can't find the some header files that declared on qandroidextras_p.h file.

and add the permission on AndroidManifest.xml file

  1. Request Permission function Requesting Android permissions in Qt 6

  2. Create Android Manifest file Where did the "Create AndroidManifest.xml" button go in Qt Creator 3.3.0?

  3. Search file on qt Recursively iterate over all the files in a directory and its subdirectories in Qt

when search files on android, root path is must be '/storage/emulated/0;' or '/mnt/sdcard'. not the QDir::rootPath();

  • Related