1.獲取("C:/Users/test/Desktop/app")
QString appPathAndName= "C:/Users/test/Desktop/app/test.exe";
- 方法一:
qDebug()<<appPathAndName.left(appPathAndName.lastIndexOf("/"));
- 方法二:
QString exeName=appPathAndName.section('/', -1); int index = appPathAndName.lastIndexOf(exeName); appPath = appPathAndName.section("",0,index-2,flag); #appPath===="C:/Users/test/Desktop/app" #exeName===="test.exe"
2.去掉file:///
QString appPathAndName= "file:///C:/Users/test/Desktop/app/test.exe";
QString absoluteFilePath = filepath.remove(0,8); //去掉 "file:///"
3.時間日期提取
QString _year = "2015年";
int year = _year.left(_year.length-1);