如何始终编译文件?
我有一个带有 QML 文件的 Qt 项目.每当我更改这些文件时,我都必须手动右键单击 .qrc(资源)文件并重新编译它.
I have a Qt project with QML files. Whenever I change these files, I have to manually right click the .qrc (resources) file and recompile it.
我如何告诉 Visual Studio总是编译某个文件,而不仅仅是在它认为它已更改时?
How do I tell visual studio to always compile a certain file, not only when it thinks it has changed?
(这里有其他人提出的类似问题 eclipse 和 flashdevelop)
(Here are similar questions others have asked for eclipse and flashdevelop)
推荐答案
我在使用 Qt Creator 构建 qt 应用程序时遇到了同样的问题.(尤其是在使用 QML 文件作为资源时.)我用一点 hack 解决了这个问题.
I encountered the same problem while building qt apps using Qt Creator.(Especially while using QML files as resources.) I solved the problem using a little hack.
- 在我的源目录中创建了一个批处理文件 touch.bat.
- 此批处理文件包含一行
copy qml.qrc/B+ ,,/Y
其中qml.qrc
是资源文件名. - 在QtCreator中打开我的项目,进入Project->Build Steps->Add Build Step->Custom process step,输入
touch.bat
- 每当项目构建开始时,就会触及
qml.qrc
.构建系统认为 qml.qrc 被修改并构建它.
- Created a batch file say touch.bat in my source directory.
- This batch file contains a single line
copy qml.qrc /B+ ,,/Y
whereqml.qrc
is the resource file name. - Opened my project in QtCreator and went to Project->Build Steps->Add Build Step->Custom process step and entered
touch.bat
- Whenever the project build starts, the
qml.qrc
is touched. The build system thinks that qml.qrc is modified and builds it.
您也可以为 Visual Studio 修改此 hack.(我没有尝试过).尝试在 Visual Studio 中添加 touch.bat
作为构建步骤.这个想法是欺骗构建系统认为您的 .qrc 已修改.
You can modify this hack for Visual Studio also.(I have not tried). Try adding touch.bat
as a build step in Visual studio. The idea is to fool the build system to think that your .qrc is modified.
我猜这是一个尚未解决的已知错误.检查此错误报告.谢谢.
I guess this is a known bug which remains unresolved. Check this bug report. Thanks.
相关文章