qt filedialog directory [duplicate]

2019-10-20 18:16发布

This question already has an answer here:

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?

2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-10-20 18:24
QFileInfo fileInfo(path);
const QString path = fileInfo.absolutePath();
查看更多
老娘就宠你
3楼-- · 2019-10-20 18:35

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).

查看更多
登录 后发表回答