qfileinfo

How to move a file to another existing directory in Qt

雨燕双飞 提交于 2019-12-04 04:14:52
问题 I am a beginner in Qt, one part of my project is moving a existing file to another existing directory? Can someone gives me a specific example? I am not sure whether I should use Qfile::rename(). I try write like this QDir::rename("/home/joshua/test.txt","/home/joshua/test/test_c.txt"); but the error is cannot call member function 'bool QDir::rename(const QString&, const QString&)' without object QDir::rename("/home/joshua/test.txt","/home/joshua/test/test_c.txt"); ^ Sorry guys, all are my

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