I cant read qrc file in Qt6
-
Hi,
I have qrc file:
<RCC>
<qresource prefix="/">
<file>qtlib/centerface.onnx</file>
</qresource>
</RCC>and I was able to copy in qt 5.15 :
if(QFile::copy("qrc:/qtlib/centerface.onnx" , tempFile)){
bc_ai = tempFile.toStdString();
}
else {
qDebug() << tempFile << "bc AI cant read" << endl;
}in qt6 its not working and cant find the centerface.onnx
any idea ?
-
Please provide a minimal, compilable example incl. your CMakeLists.txt
Also please format you code with the code-tags so it's readable. -
Christian is right that proper formatting + a full compilable example would help . Anyhow, I think I spotted the issue already:
if(QFile::copy("qrc:/qtlib/centerface.onnx" , tempFile)){
Use ":/qtlib/centerface.onnx" here, since QFile expects a file path, not a QUrl.
(And yes, the difference between :/ and qrc:/ is very annoying, as you need to know the signature of the API to decide which one to use).