How to always compile a file?

2019-02-27 09:30发布

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.

How do I tell visual studio to always compile a certain file, not only when it thinks it has changed?

(Here are similar questions others have asked for eclipse and flashdevelop)

1条回答
来,给爷笑一个
2楼-- · 2019-02-27 10:11

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.

  • Created a batch file say touch.bat in my source directory.
  • This batch file contains a single line copy qml.qrc /B+ ,,/Y where qml.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.

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.

查看更多
登录 后发表回答