Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize Program Packaging and Publishing by using windeployqt tools in Qt

2025-01-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces Qt how to use windeployqt tools to achieve program packaging and release, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

The dynamic link library method used in the official development environment of Qt requires a lot of dll to be copied when releasing the generated exe program. If you copy dll yourself, it is likely to lose everything, resulting in exe not working properly on other computers. So there is a tool that comes with Qt's official development environment: windeployqt.exe.

Take the official Qt5.4.0 + MinGW development environment as an example. The windeployqt tool is located in the% QTDIR%\ Qt5.4.0\ 5.4\ mingw491_32\ bin directory, where QTDIR is the installation directory of Qt and is the environment variable.

In the integrated development environment QtCreator, you can choose "Qt Widgets Application" or "Qt Quick Application" to generate graphical interface applications.

The release methods for creating applications in these two ways are described below.

1. Qt Widgets Application

First create a new Qt Widgets Application project with QtCreator, just use the default QMainWindow program, and the project name is assumed to be hellomw.

Then compile and generate the exe program in Release mode:

After the generated program is running properly, find the build directory of the project, such as the project source path: C:\ QtPros\ hellomw\.

Its project build directory is C:\ QtPros\ build-hellomw-Desktop_Qt_5_4_0_MinGW_32bit-Release\.

Enter this folder, go to its subfolder release, find hellomw.exe, and copy the exe to a new separate folder for publishing, such as saving to the D:\ hellomw\ folder.

Then open the Qt command line from the start menu and enter the command: cd / d D:\ hellomw

Then use the windeployqt tool command of the Qt installation directory (such as D:\ Qt\ 5.15.0\ msvc2019\ bin): d:\ Qt\ 5.15.0\ msvc2019\ bin\ windeployqt hellomw.exe

Then you can see the plug-in folder, dll file and qm file automatically copied by the windeployqt tool in the D:\ hellomw folder. At this time, you will get a complete set of exe program releases, and the dependencies will be solved.

Package the D:\ hellomw folder and release it instead of looking for dll files one by one. The qm file in the D:\ hellomw folder is a multi-language translation file, so you can delete it without needing it, and keep the rest.

2.Qt Quick Application

First create a new Qt Quick Application project with QtCreator, directly use the default project template, and click next to generate the project. The name of the project is assumed to be helloqml.

Then compile and generate the exe program in Release mode:

Then find the build directory of the project, such as the project source directory C:\ QtPros\ helloqml.

Its build directory is: C:\ QtPros\ build-helloqml-Desktop_Qt_5_4_0_MinGW_32bit-Release\.

Enter this directory, then go to the release subfolder, find helloqml.exe, and copy it to a new separate folder, such as D:\ helloqml\ folder.

Then open the Qt command line from the start menu and go to the D:\ helloqml\ folder: cd / d D:\ helloqml

Then use the windeployqt tool command: windeployqt helloqml.exe-- qmldir C:\ Qt\ Qt5.4.0\ 5.4\ mingw491_32\ qml

Be careful not to copy the last order exactly as you did! -qmldir indicates the location of the qml folder in the Qt library. In the above command, C:\ Qt\ Qt5.4.0 is the folder installed in the official development environment of Qt, and C:\ Qt\ Qt5.4.0\ 5.4\ mingw491_32 is the directory (QTDIR) of the Qt library, so use-- qmldir is followed by C:\ Qt\ Qt5.4.0\ 5.4\ mingw491_32\ qml. The installation path for the reader's Qt environment is different. Should be modified according to the actual situation!

Then you can see that there are a lot of files in the D:\ helloqml folder, which are the dependent files needed by the QtQuick program. Package the entire D:\ helloqml folder and publish it for use on other computers.

There are a lot of things in this D:\ helloqml folder. If you don't understand it, don't delete it. Just pack it and release it honestly.

The above is the simplest program release, the actual complex program may also bring some picture files, database files, configuration files and so on, you can add these files to the release folder as needed.

Thank you for reading this article carefully. I hope the article "Qt how to use windeployqt tools to achieve program packaging and release" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report