Qt编译成功后,当很多项目联合调试的时候,经常要拷贝文件。
先给出参考地址:
qt - QMake - how to copy a file to the output - Stack Overflowhttps://stackoverflow.com/questions/3984104/qmake-how-to-copy-a-file-to-the-output其中有一个提到拷贝函数,
defineTest(copyToDestDir)
Copying files with qmake | Declaration of VARCopying files with qmakehttps://decovar.dev/blog/2018/06/08/qmake-copy-files/不过这里很多会给你讲一大堆文件架构啦,如何使用啦,blabla道理一大堆;实际上,要快速上手,只需要一个简单的例子就够了,什么都不用解释,
FROM_FILES += \
$$OUT_PWD/debug/TestServer.exe
# copies the given files to the destination directory
defineTest(copyToDestDir) {
files = $$1
dir = $$2
# replace slashes in destination path for Windows
win32:dir ~= s,/,\\,g
for(file, files) {
# replace slashes in source path for Windows
win32:file ~= s,/,\\,g
QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$shell_quote($$file) $$shell_quote($$dir) $$escape_expand(\\n\\t)
}
export(QMAKE_POST_LINK)
}
copyToDestDir($$FROM_FILES, E:/vQt/EasyMessage/install/)
很简单就同把TestServer.exe这个文件拷贝到E:/vQt/EasyMessage/install/TestServer.exe;关于参数$$PWD,$$OUT_PWD,大家随便搜索一下就可以了,这些是QtCreator预定义的参数。
简单吧!
本文结束。