Qt實現複製文字
阿新 • • 發佈:2018-12-04
在.cpp實現檔案中程式碼如下:
mFilePath = new QLineEdit(this);
mFileName = QFileDialog::getOpenFileName(this,tr("Open File"));
mFilePath->setText(mFileName);
HelperPrintf("current file name is: %s",mFileName);
QFile file(mFileName);
QFileInfo info(mFileName);
QString dstPath = QString(DST_FILE_PATH) + QString("/");
QDir directory ;
directory.cd(dstPath);
dstPath += info.fileName();
file.copy(dstPath);
file.close();
QFile checkPath(dstPath);
if(checkPath.open(QFile::ReadOnly))
{
QMessageBox msgBox;
msgBox.setText("File copy success!");
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.exec();
}
checkPath.close();