Qt实现复制文本

在.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();

猜你喜欢

转载自blog.csdn.net/qq_33485434/article/details/82414692