2016-08-26 3 views

답변

1

당신은 QStandardPaths를 사용하여 바탕 화면에 경로를 얻을, 다음 QFile::copy에 호출에 해당 경로를 사용해야합니다.

당신이 복사하는 동안 파일 이름을 유지하려면 가정, 당신의 코드는 다음과 같을 것이다 : 나는 바탕 화면에 대처 근무

QString filePath = QFileDialog::getOpenFileName(this , 
               QObject::tr("Pdf files"), 
               "C:/", "books(*.pdf)"); 
QFileInfo fi(filePath); 
QString fileName= fi.fileName(); 
QString desktopPath = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); 
QString destinationPath= desktopPath+QDir::separator()+fileName; 
if(QFile::copy(filePath, destinationPath)) 
    qDebug() << "success"; 
else 
    qDebug() << "failed"; 
+0

. 다른 디렉토리에 저장하려면 QStandardPath 함수를 변경해야합니까? –

+0

질문이 명확하지 않은 경우, 다른 디렉토리는 무엇입니까? 그것은 표준 경로입니까 아니면 절대 경로가 있습니까? – Mike

+0

예 : 내 문서로 복사하려는 경우 –