qt iOS app 如何获取共享文件夹文件,如何使用document文档目录文件

how to get sharing document directory is something different with other qt platforms.

IOS app always use files only in app's sandbox. So we just need to find it's sandbox directory.

we may think following would work:

QString docPath;
    QDir dir;
    docPath=dir.currentPath();
    
however in qt 5.5 IOS, it return only root directory "/",

then we use another way:

docPath=QCoreApplication::applicationDirPath();

result is "/private/var/mobile/Containers/Bundle/Application/D31978DF-1A05-4AB9-9C36-18EA2B9E5294/testXXX.app",

is that the real sandbox directory? The answer is still no, because we can not show any files sync-in iPhone to testXXX app by iTunes.

(in qt .pro file,  we add lines

QMAKE_INFO_PLIST += aaa.plist

in aaa.plist we add "UIFileSharingEnabled true" to enable file sharing with iTunes.)

We have no patience to find other qt traditional way to solve this problem. We use mix IOS obj-c and qt c++ as follows:


QString iOSObj::getDocDir(void)
{
    iOSObj::g_iOSObj = this;
    //get Documents path
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
    NSString *path=[paths objectAtIndex:0];
NSLog(@"path:%@",path);
    QString temp = QString::fromNSString(path);
    return temp;
}

Finally, the result is

“/var/mobile/Containers/Data/Application/BB26B5E6-3340-4601-A81B-DE5362B1C938/Documents”







评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值