为什么Qt资源是在Linux而不是Windows中加载的?

时间:2017-08-19 23:53:51

标签: c++ linux windows qt qt-creator

我正在尝试通过qrc文件将一些PNG图标和一些文本文件加载到我在Qt Creator中创建的Qt程序中,但是在UI编辑器和Linux中,各个图像显示在工具栏上(应该如此) ,在Windows中编译时,按钮是空白的。我甚至试过

QImage img(":/icons/debug.png");
qDebug() << img.isNull(); // true

我的源文件和.pro文件在basedir / src /中,资源和.qrc文件在basedir / src / res /

我有什么问题吗?如果是这样,为什么这适用于Linux而不是Windows?

编辑:

qDebug() << QImageReader::supportedImageFormats(); // ("bmp", "cur", "dds", "gif", "icns", "ico", "jpeg", "jpg", "pbm", "pgm", "png", "ppm", "svg", "svgz", "tga", "tif", "tiff", "wbmp", "webp", "xbm", "xpm")

这是我的qrc文件。

<RCC>
    <qresource prefix="/icons">
        <file>sphere-icon.png</file>
        <file>project-properties.png</file>
        <file>debug.png</file>
        <file>qsi-icon.png</file>
    </qresource>
    <qresource prefix="/dictionaries">
        <file>Enums.txt</file>
        <file>LegacyFunctions.txt</file>
        <file>MiniSphereObjects.txt</file>
    </qresource>
</RCC>

1 个答案:

答案 0 :(得分:0)

好吧,我不知道为什么会这样,但是在清理和重建一百次之后,删除.pro.user文件,删除我的临时文件夹(我在项目文件中设置以保留更多内容)有组织的),从项目文件中删除.qrc文件引用,然后重新启动,突然一切正常

相关问题