QT5 packaged release

1 Overview

 When we use QT written a software program that you want to share it when it was impossible to compile a catalog copy to someone else to run. Compiled program should be a main program, add some resource files, plus some of the dynamic link library, some tall can also do an installation file.

When QT development program released frequently used in two ways:

l static compiler can generate a single executable file.

l dynamic compilation, the need to be accompanied dll file needed.

 2. Release Readiness

 Either way, we need to first publish the project to do some preparation, such as: preparing the program's icons, the project is compiled into release and so on.  

Icon for the application in two ways:

l main window icon, the main window is displayed in the upper left corner, or displayed on the taskbar in the program is running.

l run the program icon, thumbnail icons are generally displayed on the desktop or in a folder, you can run the program after the click.

 Setting the application icon

Use .ico file.
First, create .ico file. Copy ico icon file to the project folder directory, rename it to "myico.ico". Then right-click the directory, create a new document, change the name to myico.rc, and enter a line of code:                    
     IDI_ICON1 ICON DISCARDABLE "myico.ico." save.
The second step, modify the project file. Qt Creator edit mode by double clicking .pro file, add the following line of code in the final surface:
  RC_FILE + = myico.rc
third step, run the program. You can see the window of the upper left corner of the icon has been replaced.

Precautions:

 It must be a picture .ico file format, image format conversion can be performed in this place by the following website

http://www.bitbug.net/

Of course, you can set the icon by other means, through an online search, there are many ways to achieve 

3. Packaging Tool 

One is QT5 comes windeployqt (this we do not need to download and install), the other is Engima Virtual Box, which is the download link Engima Virtual Box 

4. Start packing 

Open a QT program, run a way to release

 Then your project folder, will generate a folder on release:

 Open the release folder, locate the .exe program in the release directory in the directory. At this point you click is run unsuccessful. Because of the lack of necessary QT libraries (Note: If your computer has been set up environment variables installed QT is possible, however, you copy this file to another computer is not running ). The copy of this .exe file out, create a separate folder and put this folder

In win10, search QT, as shown below:

 

Open, enter the following command:

Then enter the command line, cd / d path (refer to the need to package the exe program directory, copy is just out of exe program located), after the transport

Enter the following command line: windeployqt program name hit Enter. This step is required for all library files are copied to the current file exe program: 

 

Then we look at the program directory as follows: 

 At this time, in the current directory can click run exe program, indicating library files have been copied to the current directory. Now just a bunch of these file is packaged.

Open run Enigma Virtual Box:

Files can care option, select all the files directly dragged into the interface box. Note to all the files and folders all dragged. Diagram is as follows: 

 

In the [Files Options] can choose whether or not to file compression

 

Then click Process start packing. 

 

After the package is complete, it will generate an EXE file, which is the final executable program can be run separately

reference:

https://www.cnblogs.com/lvdongjie/p/7250547.html

https://blog.csdn.net/windsnow1/article/details/78004265

Published 47 original articles · won praise 121 · views 680 000 +

Guess you like

Origin blog.csdn.net/guoyunfei123/article/details/105034225