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. How can I add some (not program) files to release?

How can I add some (not program) files to release?

Scheduled Pinned Locked Moved General and Desktop
additional file
3 Posts 3 Posters 792 Views
  • 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.
  • A Offline
    A Offline
    Alfred Plohoy
    wrote on 27 Jul 2015, 07:55 last edited by
    #1

    In my program i need to show some articles to user.
    These articles are stored in some *.txt files.
    When I build program, files are not copied to release directory.
    Why.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 27 Jul 2015, 08:32 last edited by
      #2

      Hi and welcome

      If you just put some text files in your project folder and load them from there,
      the tool has no way of knowing you want them
      included as they are not really part of the project.

      You could add a Resource file and put the text files there. It would then be compiled into your program and
      you can load from the internal resource. that way they would always be there.
      To load from resource one uses the ":" syntax.
      After adding the text file to "Resources" , you can right click it to get path.

      Resource common ( ":/phrases/Resources/Phrases/Common.xml" );
      
      QFile commonFile ( common.absoluteFilePath() );
      
      if ( !commonFile.open ( QIODevice::ReadOnly | QIODevice::Text ) )
      {
          qDebug() << "Unable to open file: " << commonFile.fileName() << " besause of error " << commonFile.errorString() << endl;
          return;
      }
      
      QTextStream in(&commonFile);
      QString content = in.readAll();
      
      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 27 Jul 2015, 09:01 last edited by
        #3

        Hi and welcome to devnet,

        @mrjj 's technique is a very good suggestion.

        If you really want your files outside of your binary for any reason, you either need to add a build step to do the copy in Qt Creator or use QMAKE_POST_LINK to setup the copy commands.

        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
        0

        2/3

        27 Jul 2015, 08:32

        • Login

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