基于@andref answer,我想到了这个,对我来说很有用(TM):
class LoggingEngineHandler : public QAbstractFileEngineHandler
{
public:
LoggingEngineHandler()
: QAbstractFileEngineHandler()
, m_lookUpInProgress(false)
, m_lookUpPaths(QRegExp("^(images|meshes|app|sounds):"))
{
// empty
}
QAbstractFileEngine* create(const QString &fileName) const override
{
if (!fileName.contains(m_lookUpPaths))
return 0;
if (m_lookUpInProgress)
return 0;
m_lookUpInProgress = true;
QFileInfo info = QFileInfo(fileName);
m_lookUpInProgress = false;
if (!info.exists())
{
assert(!Utilities::isRunByUser("designer"));
LOG_WARN("Required resource file does not exist: %1%", QUtil_s(fileName));
}
return 0;
}
protected:
mutable bool m_lookUpInProgress;
QRegExp m_lookUpPaths;
};