首页
编程语言
数据库
网络开发
Algorithm算法
移动开发
系统相关
金融统计
人工智能
其他
首页
>
> 详细
COMP282讲解 、辅导 C++编程设计
University Of Liverpool Department of Computer Science
COMP282 – The C++ Programming Language
GUIDE TO Qt APPLICATION DEPLOYMENT
Document Version 1.1
For submission of your C++ / Qt programming assignment, we require two things:
(1) The source code (your cpp and h files)
(2) The application, packaged for deployment.
The above two items need to be in a ZIP file, with two zip files inside:
source.zip for the source code files, and
application.zip for the application package.
We will be using a Windows PC to test the application, so your solution should be packaged for
Windows deployment. The easiest way to do this is to make sure your project runs from Qt
Creator on a Windows PC, and follow the deployment steps (below) on that Windows machine.
Note: If you have not been able to use Qt, and have opted to submit a console-based application
(you will lose marks for this but at least you will be able to submit a C++ application) then you
should zip up the Visual Studio project folder, as was done for Assignment1. Make sure that
source files are included.
1. Packaging your Qt application for Windows Deployment:
The Windows deployment tool windeployqt automates creating a deployable folder
with the necessary Qt dependencies (libraries, QML imports, plugins, and translations) to
run an application. This folder forms an installation tree suitable for Windows desktop
applications, facilitating the packaging into an installer.
First lets establish where your QT directory is. Open a command window: hold down the
windows key and tap R, then type cmd and click OK:
On my laptop, I have a folder called QT on my c: drive and it looks like this:
You’ll see there is a folder called 6.3.1 (which is the version of Qt I am using – yours may
differ). Inside that is:
And now you can see the mingw_64 folder. This is the compiler folder. My installation uses
the MinGW_64 compiler (Minimalist GNU for Windows 64-bit). Yours will probably be the
same although it is possible yours may use MSVC or Clang. Either way, the folder name in
here is the last part of your Qt Directory (QTDIR).
So in my case, my QTDIR is C:\QT\6.3.1\mingw_64\
Make a note of yours and navigate to it in the command window.
(in my case I would type cd C:\QT\6.3.1\mingw_64\)
The deployment tool we need is called windeployqt and is in the QTDIR/bin/folder.
so when in your QTDIR folder, type:
cd bin
my folder looks like this (type dir /w or just dir to list the contents)
windeployqt requires either an .exe file or a directory containing an .exe file as an
argument, and examines the executable for dependencies.
It then copies any identified dependencies to the directory of the executable.
windeployqt modifies the hardcoded local paths in Qt6Core.dll to relative ones.
For Windows applications, essential compiler runtime files are also transferred to the
deployable folder by default.
The tool does not account for additional third-party libraries, such as database libraries, that
the application might need. But you are not likely to have used third party libraries so this
shouldn’t be an issue.
Further details on additional arguments can be found in the tool's help documentation. To see
that, type
windeployqt –help
[If this command doesn’t work, you may need to run the script QTDIR/bin/qtenv2.bat to set
it up. ]
2. Packaging resource files (e.g. image files)
You may be using image files (e.g. the playing card images). The executable needs to know
where to find them and you need to tell windeployqt to package them up. Your
pathname for the images probably won’t work on another computer so we have to use
relative pathnames and package the images folder in the correct place.
There are at least two ways to do this. I will describe both here.
How to choose the method?
If your project source code does not know the names of the image files in advance (e.g. it
extracts all files ending in *.png from a folder like the Memory Card Game did), then you
should use Method 1, which reproduces the images folder on the target system.
If your project source code knows the exact filename of all the images used and loads
them individually using the exact filename (i.e. no wildcards) then use Method2.
Method 1 – manually including the image folder
The simplest way is to put your images folder into the project output folder, and then make
the image filenames in the code refer to them with relative paths. We do this as follows:
Your project’s output folder will be generated by Qt Creator when you first build/run a
project. So in my case, with the memory card game, my output folder is:
build-example6-Desktop_Qt_6_3_1_MinGW_64_bit-Debug
If you want to find out what your project’s output folder is you can use this in your project
code :
qDebug() << "Executable directory:" << QCoreApplication::applicationDirPath();.
Here you can see I have copied my images folder into my project output folder.
Once the images folder is in the output folder, you need to change the image filenames in the
source code. E.g. in the memory card source code, this:
QDir directory(“C:/Users/andyrox/Documents/qt_examples/images/animal_images”);
becomes this:
QDir directory(QCoreApplication::applicationDirPath() + "/images/animal_images");
Check that this still works when you run the application from Qt Creator.
Now we come to packaging the application. For this we use windeployqt from the
command line.
From the command line, go to your compiler’s binary folder.
in my case (and in most cases) this is:
cd C:QT\6.3.1\mingw_64\bin
(The version number 6.3.1 may be different on your system)
Then we run windeployqt. The syntax is:
windeployqt
In my case I would type:
windeployqt C:\Users\andyrox\Documents\qt_examples\build-example6-
Desktop_Qt_6_3_1_MinGW_64_bit-Debug\debug
This will copy most of the required Qt dependencies into the project output folder.
So now my project output folder looks like this (you can see that there are extra folders and
dll files):
Now we need to make sure that required dlls from the compiler’s bin folder are included in
the application. You need to copy these files (highlighted in grey):
and put them in your output folder.
So now my output folder looks like this:
Now you should be able to zip up everything in the output folder to a zip file (call it
application.zip).
You can test if it has worked by unzipping the folder on another machine and running the
executable. If your game works, it’s been packaged and deployed correctly.
Method 2 – Using the Resource Collection File
There is a more sophisticated way to do it, which is to use a Resource Collection File
(resources.qrc), which specifies all the images used by the project and packages them up.
Then you change the filenames for the images to redirect them through the QRC file by using
a colon (:).
However this more sophisticated way only works if you are individually loading the images
using their specified filenames. Here are the steps:
(1) You need to make a file called a Resource Collection File with the filename
resources.qrc
In this file you need to list all the images you use in the project.
This is an example qrc file for the playing cards. Obviously my file paths will be different to yours, so
you will need to ‘search and replace’ my paths with yours, so that they are pointing to the files on
your computer
联系我们
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-21:00
微信:codinghelp
热点文章
更多
讲解 econ1202 – quantitativ...
2024-11-22
辅导 msds 490: healthcare an...
2024-11-22
讲解 civl 326 geotechnical d...
2024-11-22
辅导 term paper medicine whe...
2024-11-22
讲解 eng3004 course work辅导...
2024-11-22
讲解 ee512: stochastic proce...
2024-11-22
辅导 geog100 ol01 - fall 202...
2024-11-22
辅导 st5226: spatial statist...
2024-11-22
讲解 ece 101a engineering el...
2024-11-22
讲解 database development an...
2024-11-22
讲解 comp3134 business intel...
2024-11-22
讲解 practice exam 2, math 3...
2024-11-22
讲解 project 4: advanced opt...
2024-11-22
辅导 38003 organisational be...
2024-11-22
辅导 economic growth调试spss
2024-11-22
辅导 ee512: stochastic proce...
2024-11-22
讲解 eesb04 "principles of h...
2024-11-22
辅导 am2060 final assignment...
2024-11-22
辅导 acfim0035 fundamentals ...
2024-11-22
辅导 stat 612 (fall 2024) ho...
2024-11-22
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 99515681 微信:codinghelp
© 2024
www.7daixie.com
站长地图
程序辅导网!