gpt4 book ai didi

c++ - 如何使 QtLinguist 随 Qt 5.9.1 一起工作?

转载 作者:可可西里 更新时间:2023-11-01 12:34:53 25 4
gpt4 key购买 nike

目标:使用 lupdate 生成/更新 Qt 小部件应用程序的 *.ts 文件。

设置:

  • Windows 7 Pro 64(也在 Windows 10 家庭版上试过)
  • 适用于 msvc2017 64 位的 Qt 5.9.1 Prebult 组件,
  • 2017 年 Visual Studio 社区。

问题:我已经从 QtCreator 运行了 lupdate,也从控制台手动运行了,但在这两种情况下都无法正常工作.消息是:

Starting external tool "C:\Qt\Qt5.9.1\5.9.1\msvc2017_64\bin\lupdate.exe" C:/Documents/Projects/untitled1/untitled1.pro WARNING: Project ERROR: Cannot run compiler 'cl'. Maybe you forgot to setup the environment?

"C:\Qt\Qt5.9.1\5.9.1\msvc2017_64\bin\lupdate.exe" finished

否则项目编译、运行和调试都没有问题,套件:Desktop Qt 5.9.1 MSVC2017 64bit(默认),这就是我认为环境设置正确的原因上。

我找不到有关此问题的任何信息。有什么想法可以让 lupdate 工作吗?

编辑:我正在添加当前设置(由 Qt 安装程序制作)的屏幕截图,以试图阐明我认为环境设置正确的原因:

工具包

cmake 配置

最佳答案

解决方案

根据 n.m. 在问题下的评论中提供的信息和建议,这是我找到的解决方案(相当 hack-ish,但不是太多):

  1. 创建一个包含以下单行内容的 translate.bat:

    "%programfiles(x86)%\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"& lupdate.exe %1

并将其放在 %{CurrentProject:QT_INSTALL_BINS} 下(在我的例子中是 C:\Qt\Qt5.9.1\5.9.1\msvc2017_64\bin)。确保 translate.bat 包含您计算机上 vcvars64.bat 的正确路径。如果需要,您也可以放置另一个版本的 vcvars

  1. Qt Creator 中选择 Tools/Options/Environment/External Tools 然后在 Linguist 添加工具 em>类别。将其命名为类似于创建/更新 TS 文件。如下设置此条目的字段:

    • 可执行文件:%{CurrentProject:QT_INSTALL_BINS}\translate.bat,

    • 参数:%{CurrentProject:FilePath},

    • 工作目录:%{CurrentProject:QT_INSTALL_BINS},

如下所示:External Tools ,然后应用更改并关闭选项窗口。

  1. 转到 Tools/External/Linguist,选择Create/Update TS files,现在它应该像往常一样完成工作。

背景

这里又是link ,由 n.m. 在评论中提供,作为此解决方案的基础。这也是 n.m. 的解释:

Running lupdate from the console most definitely requires that you run vcbars*.bat as described in the link I gave you. That's because lupdate wants to run the compiler and it has no idea where to find it. vcbars*.bat tweaks your PATH and other environment variables. In theory the GUI should set up the environment for you, but in practice it probably doesn't.

关于c++ - 如何使 QtLinguist 随 Qt 5.9.1 一起工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44852340/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com