Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Do Qt Programs Have Permssion to Copy Files to the Users Directory?

Do Qt Programs Have Permssion to Copy Files to the Users Directory?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 436 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    brazz
    wrote on last edited by
    #1

    I am trying to copy a file from a qrc resource location to a temporary location where microsoft word can open it. The copy() method in the code below returns false. Any ideas why? I think it might be because the program doesn't have permission to copy the file to the user directory.

    const QString GNULicenseCopyDirectory = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
    if (QFile::exists(GNULicenseCopyDirectory + "/COPYINGtemp.docx"))
        {
            QFile::remove(GNULicenseCopyDirectory + "/COPYINGtemp.docx");
        }
    bool results = QFile::copy(":/resources/Copying.docx",
    GNULicenseCopyDirectory + "/COPYINGtemp.docx");
    QDesktopServices::openUrl("file:///" + GNULicenseCopyDirectory + "/COPYINGtemp.docx");
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Are you sure the qrc path is correct ?

      You should also consider putting the path to the temp file in a variable. You are calling GNULicenseCopyDirectory + "/COPYINGtemp.docx" four times thus it means that if you modify the file name for whatever reasons, you'll have to do it also four times.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved