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 to import an execution file into a Qt application?
Forum Updated to NodeBB v4.3 + New Features

How to import an execution file into a Qt application?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 1.1k 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.
  • K Offline
    K Offline
    Kien Bui
    wrote on last edited by
    #1

    I have an execution file.
    I want to import/attach/include,...(I don't know exactly) this file to project.
    After build. I have a Qt application.
    The first run Qt app, the an execution file export to path of Qt app.
    How to do this?

    raven-worxR 1 Reply Last reply
    0
    • K Kien Bui

      I have an execution file.
      I want to import/attach/include,...(I don't know exactly) this file to project.
      After build. I have a Qt application.
      The first run Qt app, the an execution file export to path of Qt app.
      How to do this?

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @Kien-Bui
      even this isn't by far not very nice, but since u asked for:

      put the executable into a qrc file and write it out:

      QFile in(":/my/executable");
      in.open( QFile::ReadOnly );
      
      QFile out( QCoreApplication::applicationDirPath() % QString("/executableName") ); // next to the application executable
      out.open( QFile::WriteOnly );
      
      out.write( in.readAll() );
      out.close();
      in.close();
      

      But you are advised to better distribute it along with your application, instead of embedding it with qrc.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      K 1 Reply Last reply
      4
      • raven-worxR raven-worx

        @Kien-Bui
        even this isn't by far not very nice, but since u asked for:

        put the executable into a qrc file and write it out:

        QFile in(":/my/executable");
        in.open( QFile::ReadOnly );
        
        QFile out( QCoreApplication::applicationDirPath() % QString("/executableName") ); // next to the application executable
        out.open( QFile::WriteOnly );
        
        out.write( in.readAll() );
        out.close();
        in.close();
        

        But you are advised to better distribute it along with your application, instead of embedding it with qrc.

        K Offline
        K Offline
        Kien Bui
        wrote on last edited by
        #3

        @raven-worx said in How to import an execution file into a Qt application?:

        But you are advised to better distribute it along with your application, instead of embedding it with qrc.

        Because my Qt app need exec a process with that file. Another way is compressed two files into a zip file.
        I don't have better solution for this.

        JonBJ 1 Reply Last reply
        0
        • K Kien Bui

          @raven-worx said in How to import an execution file into a Qt application?:

          But you are advised to better distribute it along with your application, instead of embedding it with qrc.

          Because my Qt app need exec a process with that file. Another way is compressed two files into a zip file.
          I don't have better solution for this.

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by JonB
          #4

          @Kien-Bui

          Because my Qt app need exec a process with that file.

          Don't understand what the relevance of that is. @raven-worx is suggesting that distributing the executable(s) as separate files is a better idea than embedding them into your executable with qrc and extracting them. And I agree with him. The fact that you will need to "exec a process with that file" has no bearing on how you distribute it, separately or embedded.

          K 1 Reply Last reply
          2
          • JonBJ JonB

            @Kien-Bui

            Because my Qt app need exec a process with that file.

            Don't understand what the relevance of that is. @raven-worx is suggesting that distributing the executable(s) as separate files is a better idea than embedding them into your executable with qrc and extracting them. And I agree with him. The fact that you will need to "exec a process with that file" has no bearing on how you distribute it, separately or embedded.

            K Offline
            K Offline
            Kien Bui
            wrote on last edited by
            #5

            @JonB seperate. OK I will try with qrc. Tks

            mrjjM 1 Reply Last reply
            0
            • K Kien Bui

              @JonB seperate. OK I will try with qrc. Tks

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Kien-Bui
              Just as note. embedding it and save to file to execute them might trigger a
              heuristics scanner the user might be using. (Avast does)
              Might not be issue in your case, but just be aware of it. :)

              1 Reply Last reply
              3

              • Login

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