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 load file from resource.
Forum Updated to NodeBB v4.3 + New Features

How to load file from resource.

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 1.9k 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.
  • Roy44R Offline
    Roy44R Offline
    Roy44
    wrote on last edited by
    #1

    Hi,

    I would like to know how to load a dwg file from qrc.
    My qrc is :

    <RCC>
        <qresource prefix="/resources/res">
            <file>../res/mediacad.lin</file>
            <file>../res/paperFrozen.png</file>
            <file>../res/paperSun.png</file>
            <file>../res/filter.png</file>
            <file>../res/freeze.png</file>
            <file>../res/layer.png</file>
            <file>../res/lightOff.png</file>
            <file>../res/lightOn.png</file>
            <file>../res/locked.png</file>
            <file>../res/print.png</file>
            <file>../res/sun.png</file>
            <file>../res/unlocked.png</file>
            <file>../res/unprint.png</file>
            <file>../res/dropDown.png</file>
            <file>../res/line.dwg</file>
            <file>../res/mediacad.pat</file>
            <file>../res/line.dwg</file>
            <file>../res/mediacad.lin</file>
        </qresource>
    </RCC>
    

    I try to load the dwg using ertenal library but the program crash in notify in my core application.
    But it works with a non resource file.

    m_pDatabase = ((MdCoreApplication*)qApp)->readFile(OD_T(":/resources/res/line.dwg"));
    

    I made

    Q_INIT_RESOURCE(resources);
    

    But the problem is not solved.
    I have no problem for icons. So what i do wrong ?
    Thanks.
    (sorry for my bad english)

    raven-worxR miclandM D 3 Replies Last reply
    0
    • Roy44R Roy44

      Hi,

      I would like to know how to load a dwg file from qrc.
      My qrc is :

      <RCC>
          <qresource prefix="/resources/res">
              <file>../res/mediacad.lin</file>
              <file>../res/paperFrozen.png</file>
              <file>../res/paperSun.png</file>
              <file>../res/filter.png</file>
              <file>../res/freeze.png</file>
              <file>../res/layer.png</file>
              <file>../res/lightOff.png</file>
              <file>../res/lightOn.png</file>
              <file>../res/locked.png</file>
              <file>../res/print.png</file>
              <file>../res/sun.png</file>
              <file>../res/unlocked.png</file>
              <file>../res/unprint.png</file>
              <file>../res/dropDown.png</file>
              <file>../res/line.dwg</file>
              <file>../res/mediacad.pat</file>
              <file>../res/line.dwg</file>
              <file>../res/mediacad.lin</file>
          </qresource>
      </RCC>
      

      I try to load the dwg using ertenal library but the program crash in notify in my core application.
      But it works with a non resource file.

      m_pDatabase = ((MdCoreApplication*)qApp)->readFile(OD_T(":/resources/res/line.dwg"));
      

      I made

      Q_INIT_RESOURCE(resources);
      

      But the problem is not solved.
      I have no problem for icons. So what i do wrong ?
      Thanks.
      (sorry for my bad english)

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @Roy44 said:

      I try to load the dwg using ertenal library but the program crash in notify in my core application.

      where does it crash exactly. Please show some code around the point where it crashes.

      But it works with a non resource file.

      what do you mean? When you simply do not try to access a file from the resource file? Or even remove the resource file from your project?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • Roy44R Roy44

        Hi,

        I would like to know how to load a dwg file from qrc.
        My qrc is :

        <RCC>
            <qresource prefix="/resources/res">
                <file>../res/mediacad.lin</file>
                <file>../res/paperFrozen.png</file>
                <file>../res/paperSun.png</file>
                <file>../res/filter.png</file>
                <file>../res/freeze.png</file>
                <file>../res/layer.png</file>
                <file>../res/lightOff.png</file>
                <file>../res/lightOn.png</file>
                <file>../res/locked.png</file>
                <file>../res/print.png</file>
                <file>../res/sun.png</file>
                <file>../res/unlocked.png</file>
                <file>../res/unprint.png</file>
                <file>../res/dropDown.png</file>
                <file>../res/line.dwg</file>
                <file>../res/mediacad.pat</file>
                <file>../res/line.dwg</file>
                <file>../res/mediacad.lin</file>
            </qresource>
        </RCC>
        

        I try to load the dwg using ertenal library but the program crash in notify in my core application.
        But it works with a non resource file.

        m_pDatabase = ((MdCoreApplication*)qApp)->readFile(OD_T(":/resources/res/line.dwg"));
        

        I made

        Q_INIT_RESOURCE(resources);
        

        But the problem is not solved.
        I have no problem for icons. So what i do wrong ?
        Thanks.
        (sorry for my bad english)

        miclandM Offline
        miclandM Offline
        micland
        wrote on last edited by micland
        #3

        @Roy44 said:

        I try to load the dwg using ertenal library but the program crash in notify in my core application.
        But it works with a non resource file.

        m_pDatabase = ((MdCoreApplication*)qApp)->readFile(OD_T(":/resources/res/line.dwg"));
        

        What happens in the readFile method? Is this directed to the external library?
        The resource handling is very Qt specific and 3rd party libraries will not understand the "qrc:/..."-Path if they are not Qt based und do not use Qt's own file handling classes.

        1 Reply Last reply
        2
        • Roy44R Roy44

          Hi,

          I would like to know how to load a dwg file from qrc.
          My qrc is :

          <RCC>
              <qresource prefix="/resources/res">
                  <file>../res/mediacad.lin</file>
                  <file>../res/paperFrozen.png</file>
                  <file>../res/paperSun.png</file>
                  <file>../res/filter.png</file>
                  <file>../res/freeze.png</file>
                  <file>../res/layer.png</file>
                  <file>../res/lightOff.png</file>
                  <file>../res/lightOn.png</file>
                  <file>../res/locked.png</file>
                  <file>../res/print.png</file>
                  <file>../res/sun.png</file>
                  <file>../res/unlocked.png</file>
                  <file>../res/unprint.png</file>
                  <file>../res/dropDown.png</file>
                  <file>../res/line.dwg</file>
                  <file>../res/mediacad.pat</file>
                  <file>../res/line.dwg</file>
                  <file>../res/mediacad.lin</file>
              </qresource>
          </RCC>
          

          I try to load the dwg using ertenal library but the program crash in notify in my core application.
          But it works with a non resource file.

          m_pDatabase = ((MdCoreApplication*)qApp)->readFile(OD_T(":/resources/res/line.dwg"));
          

          I made

          Q_INIT_RESOURCE(resources);
          

          But the problem is not solved.
          I have no problem for icons. So what i do wrong ?
          Thanks.
          (sorry for my bad english)

          D Offline
          D Offline
          Devopia53
          wrote on last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • Roy44R Offline
            Roy44R Offline
            Roy44
            wrote on last edited by
            #5

            Thanks for your answer.
            ReadFile comes from external non Qt library.

            miclandM 1 Reply Last reply
            0
            • Roy44R Roy44

              Thanks for your answer.
              ReadFile comes from external non Qt library.

              miclandM Offline
              miclandM Offline
              micland
              wrote on last edited by
              #6

              @Roy44
              Does your 3rd party library provide any read-method that accepts anything else than a filename? Perhaps you can read the resource as byte array and pass it to the library...

              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