Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. I cant read qrc file in Qt6
Forum Updated to NodeBB v4.3 + New Features

I cant read qrc file in Qt6

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 381 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RahibeMeryem
    wrote on last edited by
    #1

    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 ?

    Christian EhrlicherC kkoehneK 2 Replies Last reply
    0
    • R RahibeMeryem

      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 ?

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Please provide a minimal, compilable example incl. your CMakeLists.txt
      Also please format you code with the code-tags so it's readable.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1
      • R RahibeMeryem

        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 ?

        kkoehneK Offline
        kkoehneK Offline
        kkoehne
        Moderators
        wrote on last edited by
        #3

        @RahibeMeryem

        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).

        Director R&D, The Qt Company

        1 Reply Last reply
        2

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved