简体   繁体   中英

Why are Qt resources being loaded in Linux but not Windows?

I'm trying to load some PNG icons and some text files into my Qt program created in Qt Creator via a qrc file, but while the respective images appear on the toolbar (as they should) in the UI editor and in Linux, the buttons are blank when compiled in Windows. I even tried

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

I have my source files and the .pro file in basedir/src/, and the resources and .qrc file in basedir/src/res/

Is there something I'm doing wrong? If so, why does this work in Linux but not Windows?

EDIT:

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

Here is my qrc file.

<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>

好吧,我不知道为什么会这样,但是在清理并重建了一百次之后,删除了.pro.user文件,删除了我的临时文件夹(我在项目文件中设置了临时文件夹,以使文件更加井井有条),然后删除了项目文件中的.qrc文件引用,然后重新启动,突然一切正常

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM