c++qtqmlqt-resource

.rcc file not found when trying to call registerSource


I have generated a .rcc file using the following command:

rcc -binary redTheme/redTheme.qrc -o redTheme.rcc

I then put the redTheme.rcc file into the binary folder. Finally, I register the file with registerResource(const QString & rccFileName, const QString & mapRoot = QString()):

QResource::registerResource("redTheme.rcc")

The method returns false. Do I need to set a path or something similar?

Note that I'm using MSVC 2013 with CMake. According to this post, it could be a problem.


Solution

  • You might need to pass an absolute path. For example:

    QResource::registerResource(QCoreApplication::applicationDirPath() + "/redTheme.rcc");
    

    One way to confirm this is to check if the following statement returns true:

    QFile::exists("redTheme.rcc")