简体   繁体   中英

Qt Resources under Linux

I want to use Qt Resources file .qrc to load resources to my soft. Under Windows, it works perfectly, but under Linux (Ubuntu 12.10), it doesn't work at all.

Here is a part of my resources.qrc file :

<qresource prefix="/ressources">
    <file alias="style">ressources/style.css</file>
</qresource>

When I open this file in my code I make something like that :

QFile file(":/ressources/style.css");

if (!file.open(QIODevice::ReadOnly))
{
    qDebug() << "open fail";
    return ;
}

open() method is unable to open that file properly.

Have you an idea ?

Thank you.

You've specified "style" as the alias, so you can only open it with:

QFile file(":/ressources/style");

However, since the prefix you specified is identical to the physical directory name, why don't you just do this instead:

<qresource>
    <file>ressources/style.css</file>
</qresource>

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