Copy path to QString

混江龙づ霸主 提交于 2019-11-28 10:53:35

问题


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

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