Each time I compile my Qt project after modifying my qss stylesheet file, the modifications aren't taken into account, unless I rebuild everything.

Any idea on a workaround for this, so that I don't have to wait 5 minutes each time I change my qss ?

Notes: I use Qt 4.8, and my stylsheet is declared in a resource file (qrc).

EDIT: As suggested by Luca Carlon, when a qss is reference in the project through a .qrc file, the changes in the qss don't affect the qrc, and the compiler ignores it. To avoid that, I added a Custom Build Step to my project:

  • before the qmake step!
  • calls a .bat file without any argument
  • the .bat contains the real command copy /b files.qrc +,,
有帮助吗?

解决方案

I experienced the same issue with QML files inside Qt resources files. I've been told by the Qt guys that this happens sometimes: I think this might be it.

To work around this issue I created a custom step in the build process: go to the project settings, under Build Steps select Add Build Step -> Custom Build Step. Here add as a Command a touch of the qrc file and position this step as the first step. If you're working under Windows use an equivalent of the touch command.

This will recompile that qrc file every time, but at least it is automatic. I couldn't find any other way at the time. If you stop working on that file, just disable the step.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top