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. Copying files from qrc suddenly stopped working
Qt 6.11 is out! See what's new in the release blog

Copying files from qrc suddenly stopped working

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 4 Posters 666 Views 2 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.
  • S Offline
    S Offline
    Sucharek
    wrote on last edited by Sucharek
    #1

    Hi, I'm trying to copy 2 files from a resource (qrc). It was working fine, untill I changed the path where I was originally copying the files to. I tried changing it back, but that also stopped working. I haven't changed anything anywhere, just the destination path.
    Here's what I have:

    QString dir = getUserPath() + "/AppData/Local/Temp/Sucharek/";
    QDir createTempFolder; createTempFolder.mkdir(dir);
    
    qDebug() << QFile::copy(":/files/drivers.zip", dir + "drivers.zip"); //returns false, the other one too
    QFile::copy(":/files/platform-tools.zip", dir + "platform-tools.zip");
    

    I have checked the spelling, the path, tried changing it to a different destination path, still returns false and doesn't work.
    Edit: The folder in specified path does exist.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Check if ``:/files/platform-tool.zip` really exists. Also use the non-static version of QFile::copy() and check the error string afterwards.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      S 1 Reply Last reply
      2
      • Christian EhrlicherC Christian Ehrlicher

        Check if ``:/files/platform-tool.zip` really exists. Also use the non-static version of QFile::copy() and check the error string afterwards.

        S Offline
        S Offline
        Sucharek
        wrote on last edited by
        #3

        Hi @Christian-Ehrlicher, :/files/platform-tools.zip and the other one exists:
        689d89fb-a9fe-4b00-997d-a0901093742f-image.png

        I used the non-static version and QFile returned Cannot open :/files/platform-tools.zip for input. Once again, I checked the spelling, paths, they do exist.
        The commands I'm using:
        QFile file(":/files/platform-tools.zip"); file.copy(dir + "platform-tools.zip"); qDebug() << file.errorString();

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Did you add a prefix or an alias to that file ?

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

          S 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            Did you add a prefix or an alias to that file ?

            S Offline
            S Offline
            Sucharek
            wrote on last edited by
            #5

            Hi @SGaist, the prefix is: /files

            JonBJ 1 Reply Last reply
            0
            • S Sucharek

              Hi @SGaist, the prefix is: /files

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6

              @Sucharek
              If nothing else is working, did you do a full clean delete and rebuild? Just to make sure the resources are properly compiled into the executable right.

              S 1 Reply Last reply
              1
              • JonBJ JonB

                @Sucharek
                If nothing else is working, did you do a full clean delete and rebuild? Just to make sure the resources are properly compiled into the executable right.

                S Offline
                S Offline
                Sucharek
                wrote on last edited by
                #7

                Hi @JonB, I did a clean build and it's working now, thanks.
                Thanks for all your replies.

                1 Reply Last reply
                0

                • Login

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