qt filedialog directory [duplicate]

限于喜欢 提交于 2019-12-13 11:17:12

问题


i got a QString blabla = qtfiledialog::getOpenFileName();

now blabla gives me the full path and the exe like: C:/Program Files/imanoob.exe

but i only want the path like: C:/Program Files/ how to do this?


回答1:


QFileInfo fileInfo(path);
const QString path = fileInfo.absolutePath();



回答2:


QString getExistingDirectory to get a directory path.

Or parse the returned string from getOpenFileName() by using QDir (probably QDir(blabla).path() although you need to check the API on the actual method to use).



来源:https://stackoverflow.com/questions/3097259/qt-filedialog-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!