问题
I need to copy the full filepath, without filename, into a QString from QFileDialog below.
QString fileName = QFileDialog::getOpenFileName(this,
tr("Select app to install"), '/' , tr("APK Files (*.apk)"));
回答1:
You use QString QFileInfo::absolutePath() const
for this. See the documentation for details.
QFileInfo fileInfo(QFileDialog::getOpenFileName(this,
tr("Select app to install"), '/' , tr("APK Files (*.apk)")));
qDebug() << fileInfo.absolutePath();
来源:https://stackoverflow.com/questions/24371152/copy-path-to-qstring