.rcc file not found when trying to call registerSo

2019-07-24 16:50发布

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.

1条回答
来,给爷笑一个
2楼-- · 2019-07-24 17:24

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")
查看更多
登录 后发表回答