I have found a few post regarding this topic, but the code used in verbatim and slightly modified gives me an error. I have a .docx
file named COPYING stored in a / prefix inside a resources folder. I would like to open this file with whatever default word editing application the system uses (most likely Word).
The code below gives me this error
ShellExecute 'file:///C:/Users/john/AppData/Local/Temp/COPYINGtemp.docx' failed (error 2).
` The issue may be that setFileName doesn't actually change location of the file? Or it seems as though the copy method doesn't actually do anything (when debugging I've looked inside the qrc directory and the temp directory and nothing is there). The copy bool results in false
QFile::copy(":/resources/COPYING.docx", ":/resources/COPYINGTemp.docx");
QFile GNULicenseCopyFile(":/resources/COPYINGtemp.docx");
const QString GNULicenseCopyDirectory = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
GNULicenseCopyFile.setFileName(GNULicenseCopyDirectory + "/COPYINGtemp.docx");
QDesktopServices::openUrl("file:///" + GNULicenseCopyDirectory + "/COPYINGtemp.docx");
the code below gives the same error
const QString GNULicenseCopyDirectory = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
QFile::copy(":/resources/Copying.docx", GNULicenseCopyDirectory + "/COPYINGtemp.docx");
QDesktopServices::openUrl("file:///" + GNULicenseCopyDirectory + "/COPYINGtemp.docx");