您当前的位置: 首页 >  qt
  • 0浏览

    0关注

    483博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Qt开发高级进阶:如何拷贝生成后的文件到特定文件夹

高精度计算机视觉 发布时间:2022-05-30 16:41:28 ,浏览量:0

Qt编译成功后,当很多项目联合调试的时候,经常要拷贝文件。

先给出参考地址:

qt - QMake - how to copy a file to the output - Stack Overflowicon-default.png?t=M4ADhttps://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预定义的参数。

简单吧!

本文结束。

关注
打赏
1661664439
查看更多评论
立即登录/注册

微信扫码登录

0.0428s