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. How to read file from QRC?
Forum Updated to NodeBB v4.3 + New Features

How to read file from QRC?

Scheduled Pinned Locked Moved Solved General and Desktop
qrc
4 Posts 2 Posters 4.1k 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.
  • D Offline
    D Offline
    Dariusz
    wrote on last edited by
    #1

    Hey

    Bit annoying but I have this in QRC:

    <RCC>
        <qresource prefix="/">
            <file>data.glsl</file>
        </qresource>
    
        <qresource prefix="/openGL/">
            <file alias="testX">file/test.glsl</file>
        </qresource>
    </RCC>
    

    And I wish to load it as :

    QString path = "/openGL/testX"
    loadShader(path);
    ....
    void loadShader(QString filePath){
        QFile v(filePath);
        v.open(QIODevice::ReadOnly);
        qDebug() << v.readAll();
        if (!mShader->addShaderFromSourceFile(QOpenGLShader::Vertex, v.readAll())) {
    

    This seems to not work...
    device not open bla bla bla...

    What to do ?

    TIA

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      When having files in a resource file, the syntax for its paths is
      ":/xxx" . note the start :
      Anyway, find the file in the project explorer tree and right click the file.
      You can then copy the complete path to use.

      alt text

      1 Reply Last reply
      4
      • D Offline
        D Offline
        Dariusz
        wrote on last edited by
        #3

        Hey

        Thanks for info!

        I had another deep look at what I was doing... I forgot to add ":" !

        "/openGL/testX"
        to
        ":/openGL/testX"

        Blindness...

        mrjjM 1 Reply Last reply
        1
        • D Dariusz

          Hey

          Thanks for info!

          I had another deep look at what I was doing... I forgot to add ":" !

          "/openGL/testX"
          to
          ":/openGL/testX"

          Blindness...

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Dariusz
          Hi
          Thats why i often use the copy trick :)
          ctrl+k type some of the name, press enter, right click and copy
          Almost as fast as writing it when i have nested folders.

          1 Reply Last reply
          0

          • Login

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