将 Qt 样式表导出到输出目录
我在 Qt 桌面应用程序(.qss 文件)中使用样式表,但我无法找到如何使 .pro 文件将 .qss 文件复制到输出目录(正在创建 .exe 文件的位置) ),这意味着应用程序完全无需任何样式即可运行。
我曾经从 Visual Studio 运行该项目,VS 会为我处理这一切。但现在我已经从 VS 导出了 .pro 文件以在 Qt Creator 中使用它,并且我认为我必须手动向 .pro 文件添加更多命令才能复制此文件。
我对 QMake 不太熟悉,但我尝试摆弄“OTHER_FILES + =”和“INSTALLS + =”命令,但我无法将样式表复制到目标目录。
如果我手动将文件复制到目标目录,一切都会像魅力一样工作,但这需要我在每次更改时手动复制它。.
关于此事的任何帮助将不胜感激。提前致谢!
I'm using a stylesheet in my Qt desktop application (a .qss file), but I can't find out how to make the .pro file copy the .qss file to the output directory (where the .exe file is being created), which means the application runs totally without any styling.
I used to run the project from Visual Studio, and VS would take care of all this for me. But now I've exported the .pro file from VS to use it in Qt Creator instead, and I reckon I have to add some more commands to the .pro file manually to get this file copied.
I am not very familiar with QMake, but I've tried fiddling around with both "OTHER_FILES +=" and "INSTALLS +=" commands, but I can't get either to copy the stylesheet over to the destination directory.
If I copy the file to the dest dir manually, everything works like a charm, but that requires me to manually copy it everytime it changes..
Any help on this matter would be greatly appreciated. Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个我已经成功使用的徽标示例:
我想您的样式表也可以使用同样的东西。请注意,每次运行安装目标时都会复制映像,而不是检查相对日期并且仅在源较新时才复制。
Here is an example with a logo that I've used successfully:
I imagine the same sort of thing could be used with your stylesheet. Do note that this copied the images every time the install target was run, instead of checking the relative dates and only copying if the source was newer.