QT创建者 - 如何存储/将选定的文件存储到项目目录
我正在尝试创建一种将文件存储在项目目录中的方法。我正在使用qfiledialog
对话框,并使用qfile :: copy()
来复制所选文件。我能够通过将其存储在项目目录(桌面)之外来使其工作。但是为此,我需要它存储在项目目录中。
如果需要,我很乐意提供其他信息。
注意:我也尝试将其存储在资源文件夹中而没有成功。顺便说一句,我是QT开发世界的新手。
QString filePath = QFileDialog::getOpenFileName(this, QObject::tr("PDF files"),
"C:/", "PDF (*.pdf) ;; JPG (*.jpg) ;; PNG (*.png)");
QFileInfo file(filePath);
QString fileName= file.fileName();
if(QFile::copy(filePath, ":/PDF/PDF/"+fileName))
qDebug() << "success";
else
qDebug() << "FAILED TO LOAD TO -> :/PDF/PDF/"+fileName;
I am trying to create a way to store file's in the project directory. I am using QFileDialog
for the dialog and using Qfile::copy()
to copy the selected file. I was able to get it to work by storing it outside the project directory (Desktop). But for this, I need it to store in the project directory.
I am more than happy to provide additional information if needed.
Note: I tried storing it in the Resource folder as well without success. BTW, I am new to qt development world.
QString filePath = QFileDialog::getOpenFileName(this, QObject::tr("PDF files"),
"C:/", "PDF (*.pdf) ;; JPG (*.jpg) ;; PNG (*.png)");
QFileInfo file(filePath);
QString fileName= file.fileName();
if(QFile::copy(filePath, ":/PDF/PDF/"+fileName))
qDebug() << "success";
else
qDebug() << "FAILED TO LOAD TO -> :/PDF/PDF/"+fileName;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论