当前位置:网站首页>Summarize the acquisition of commonly used file information QFileInfo in Qt: suffix, name, path, link
Summarize the acquisition of commonly used file information QFileInfo in Qt: suffix, name, path, link
2022-08-11 00:50:00 【Trendy Technology Research Institute】
Because I have been manipulating the relevant properties of files recently, I took a look at QFileInfo and found that many functions are usually forgotten, such as basename(), suffix(), which are very common, but sometimes I don't remember them.It is also possible to use QString's split to manipulate strings, but it is not so convenient, so summarize and record them.
1. Get the suffix of the file name:
QFileInfo fi("/tmp/archive.tar.gz");QString ext = fi.suffix(); // ext = "gz"2. Get all suffixes after the file name symbol point:
QFileInfo fi("/tmp/archive.tar.gz");QString ext = fi.completeSuffix(); // ext = "tar.gz"3. Get the absolute path of the file name (the drive letter will be capitalized automatically under Windows):
QFileInfo fi("c:/temp/foo"); => fi.absoluteFilePath() => "C:/temp/foo"4. Get all strings of the file name except the suffix of the last symbol point:
QFileInfo fi("/tmp/archive.tar.gz");QString base = fi.completeBaseName(); // base = "archive.tar"边栏推荐
猜你喜欢

详解JDBC的实现与优化(万字详解)

Two-dimensional array combat project -------- "Minesweeper Game"

How engineers treat open source

【C语言】探索数据的存储(整形篇)

微信小程序通过URL Scheme动态的渲染数据

Dual machine thermal for comprehensive experiment (VRRP + OSPF + + NAT + DHCP + VTP PVSTP + single-arm routing)

J9 Digital Theory: DAO governance is more like an ecological process: governance is native to the network and continues to evolve

sed of the Three Musketeers of Shell Programming

BEVDepth: Acquisition of Reliable Depth for Multi-view 3D Object Detection Paper Notes

分库分表ShardingSphere-JDBC笔记整理
随机推荐
云原生-VMware虚拟机安装Kubesphere实战(一)
什么是数组
详解JDBC的实现与优化(万字详解)
Use mysql statement to operate data table (table)
Jvm. Profiling tools (jconsole, jvisualvm, arthas, jprofiler, mat)
networkmanager无法打开
#yyds干货盘点#【愚公系列】2022年08月 Go教学课程 008-数据类型之整型
PMP每日一练 | 考试不迷路-8.10(包含敏捷+多选)
How to do patent mining, the key is to find patent points, in fact, it is not too difficult
成功解决TypeError: can‘t multiply sequence by non-int of type ‘float‘
【pypdf2】合并PDF、旋转、缩放、裁剪、加密解密、添加水印
Linux install redis database
J9 Digital Theory: DAO governance is more like an ecological process: governance is native to the network and continues to evolve
HW-常见攻击方式和漏洞原理(2)
【pypdf2】安装、读取和保存、访问页面、获取文本、读写元数据、加密解密
如何破坏Excel文件,让其显示文件已损坏方法
[21 Days Learning Challenge] Half Insertion Sort
C# JObject解析JSON数据
YOLOv5的Tricks | 【Trick11】在线模型训练可视化工具wandb(Weights & Biases)
[GXYCTF2019]BabySQli