当前位置:网站首页>手机连接电脑后,QT的QDIR怎么读取手机文件路径
手机连接电脑后,QT的QDIR怎么读取手机文件路径
2022-04-23 03:08:00 【Intimes】
大家都知道Qt的QFileSystemModel类可以建立硬盘上的文件资源模型,从而实现简单的文件管理和文件夹管理,那么手机中的文件该怎么获取呢?这里做i用个小测试:
话不多说 直接上代码:
QString filedir = QCoreApplication::applicationDirPath();
QString filename = QFileDialog::getOpenFileName(
this,
"请选择要打开的video.m4s文件",
filedir,
"m4s (video.m4s)");
// 取消打开则返回
if(filename==QString(""))
return;
// 写入文件路径
ui->lineEdit->setText(filename);
在槽函数中直接敲如上述代码,就可以实现打开文件对话框,寻找文件。通常我们是才自己电脑查找文件,比如:

这时候,我把我心爱的小手机用USB连接电脑,打开文件操作权限,试一下,哎可以看手机文件了

这就是Android手机的内部文件了。好,这时候,我们继续测试我们的代码,把目录切换到手机目录下,并找到想打开的B站文件,比如:

这个文件通常在android/data/tv.danmuku.bili/download/xxxxxxx/c_xxxxxxx/xx/下面。大家注意看上图的路径。这时候打开,结果文件路径就会变成这样:

看看,是不是发生了改变,我贴出这个路径是:
C:/Users/Jo/AppData/Local/Microsoft/Windows/Temporary Internet Files/Content.IE5/NY2XOM6A/video[1].m4s
C:/Users/Jo/AppData/Local/Microsoft/Windows/Temporary Internet Files/Content.IE5/4I7OJ28R/audio[1].m4s
也就是说,手机文件其实是存在临时文件中的。我们用资源管理器找到这个路径,注意这个路径是隐藏的,需要在设置中把隐藏系统文件取消勾选才能找到。这个路径也可用浏览器打开,就类似于FTP服务器那样:

你会发现,里面文件真的是很乱,也不是你手机中的文件,就全都是临时文件。你刚才找到的手机文件,也会在临时文件中。
所以说,想用QT实现文件系统模型,还是任重道远啊!
尽管如此,还是实现了读取手机文件,这就是个进步了。
版权声明
本文为[Intimes]所创,转载请带上原文链接,感谢
https://blog.csdn.net/zjjsd195/article/details/124262191
边栏推荐
- Mise en service PID du moteur de codage (anneau de vitesse | anneau de position | suivant)
- ASP. Net 6 middleware series - Custom middleware classes
- AOT和单文件发布对程序性能的影响
- 先中二叉建树
- MYSQL04_ Exercises corresponding to arithmetic, logic, bit, operator and operator
- [new version release] componentone added Net 6 and blazor platform control support
- Opencv combines multiple pictures into video
- 2022年度Top9的任务管理系统
- 由于3²+4²=5²,所以称‘3,4,5‘为勾股数,求n(包括n)以内所有勾股数数组。
- ASP.NET和ASP.NETCore多环境配置对比
猜你喜欢

最通俗易懂的依赖注入与控制反转

The most easy to understand dependency injection and control inversion

Laravel8- use JWT

Source Generator实战

树莓派开发笔记(十二):入手研华ADVANTECH工控树莓派UNO-220套件(一):介绍和运行系统

2022年度Top9的任务管理系统

MYSQL04_ Exercises corresponding to arithmetic, logic, bit, operator and operator

最通俗易懂的依赖注入之生命周期

Opencv combines multiple pictures into video

C语言实现通讯录----(静态版本)
随机推荐
基于.NetCore开发博客项目 StarBlog - (1) 为什么需要自己写一个博客?
Golden nine silver ten interview season, you are welcome to take away the interview questions (with detailed answer analysis)
LNMP MySQL allows remote access
Openfeign service call
Laravel8- use JWT
OLED多级菜单记录
使用DFS来解决“字典序排数”问题
.NET点滴:说说Middleware构造中获取不到Scoped服务的问题
A set of C interview questions about memory alignment. Many people make mistakes!
全网最全,接口自动化测试怎么做的?精通接口自动化测试详解
TP5 customization in extend directory succeeded and failed. Return information
Swap the left and right of each node in a binary tree
【新版发布】ComponentOne 新增 .NET 6 和 Blazor 平台控件支持
In redis cluster, the master node fails, and the IP changes after the master-slave switch. The client does not need to deal with it
Onenet connection process
Introduction and use of openfeign component
Systemctl start Prometheus + grafana environment
編碼電機PID調試(速度環|比特置環|跟隨)
Ningde's position in the times is not guaranteed?
C# 11 对 ref 和 struct 的改进