gpt4 book ai didi

c++ - 图像文件的 Qt QRC 文件路径不起作用

转载 作者:行者123 更新时间:2023-11-30 02:41:42 26 4
gpt4 key购买 nike

我在 Mac 上开发,我在 QRC 路径上没有问题,在切换到 Windows 后,图像链接停止工作。但是 qss 文件可以被引用并且正在工作!

1) 我从头开始创建了一个新的资源文件

2) 我重建了项目

3)我用的是qt下发的路径:

enter image description here

4) 完整路径有效:

QVariant(QIcon(QPixmap("V:/070_RnD/AssetBrowser_02/images/checkbox.png")));

5) QRC-Path 不是

QVariant(QIcon(QPixmap(":/myresources/images/checkbox.png")));

我还能测试什么?屁股我说,当我从 default.qss 复制资源路径时它被识别,但图像不是。

二维码:

<RCC>
<qresource prefix="/myresources">
<file>images/scrollHandle.png</file>
<file>images/upArrow.png</file>
<file>images/downArrow.png</file>
<file>images/folder-icon.png</file>
<file>images/branch-closed.png</file>
<file>images/branch-open.png</file>
<file>images/checkbox.png</file>
<file>qss/default.qss</file>
</qresource>
</RCC>

最佳答案

您使用的资源路径看起来与您的 qrc 文件兼容。所以 Qt 资源编译器可能错过了您的 qrc 文件。

检查您的 qrc 文件是否包含在 .pro 文件中,如下所示。

RESOURCES += \
Style.qrc

如果它正确地包含在 .pro 文件中,则尝试 Build->Run QMake 然后 Build->Rebuild project。这将重新生成 makefile 并重建项目。

关于c++ - 图像文件的 Qt QRC 文件路径不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27842392/

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