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. [SOLVED] - Get in trouble with resource file
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] - Get in trouble with resource file

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 3.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.
  • S Offline
    S Offline
    saobien39
    wrote on last edited by
    #1

    Well, I want add icon at project. I follow " this guide ":http://doc.qt.nokia.com/qtcreator-2.3/creator-writing-program.html to create resource file. We also know folders as Headers, Sources, Resources are only "logical" folder which Qt creator built to manage easily. But really I see file .qrc was placed in Resources, In folder root project, I created 1 folder to store image called "images", so folder "physical" images have level equivalent as folder Resources in tree? If I write content of file .qrc following:

    @<!DOCTYPE RCC><RCC version="1.0">
    <qresource>
    <file>images/icon.png</file>
    </qresource>
    </RCC>@

    File .qrc is placed in Resources folder can "see" file .png in folder images?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      saobien39
      wrote on last edited by
      #2

      Maybe I find a little mistake, resource file itself uses a XML format.

      First, I think it's so: (rc.txt contain code XML above)

      !http://nn2.upanh.com/b6.s27.d2/f61458c20b96967cffebd8dbe08de609_45928952.h1.png(1)!

      Really, It must have following structure: :)

      !http://nn0.upanh.com/b4.s26.d1/b3d86be905d09bfcffd3b0175bbc714d_45929000.h2.png(2)!

      ps: Author of some books has sense of humor, they describe content of file .qrc while we never have opportunity to see it.

      1 Reply Last reply
      0
      • EddyE Offline
        EddyE Offline
        Eddy
        wrote on last edited by
        #3

        The prefix you use in the resource file can be something else than the folder you use on your hard disk.
        Eg. If you have a folder /images, you can use a prefix /img in the resource file.

        When you use Qt Designer / Qt Creator, you use the add button to browse for image files on your hard drive. I always do it like this. You could try it out and afterwards have a look at the file to see how it works.

        Qt Certified Specialist
        www.edalsolutions.be

        1 Reply Last reply
        0
        • S Offline
          S Offline
          saobien39
          wrote on last edited by
          #4

          @Eddy: Having something I don't understand. I modify prefix following:

          !http://img401.imageshack.us/img401/2613/47682466.png(qrc)!

          I think when I add file icon.png at tree. It only shows file name (icon.png), in fact, it still need name of folder containing it (images/icon.png) ?

          1 Reply Last reply
          0
          • EddyE Offline
            EddyE Offline
            Eddy
            wrote on last edited by
            #5

            The /images/icon.PNG has that extra path info because it is in a subfolder /images.

            Have you tried using the icon.png using Qt Creator?
            Go to a ui and add a QLabel to it. Then in the properties of that label go to pixmap, click on the button on the right (shows up when you click in inputfield) and a dialog appears which shows your resource system. Click on the icon.png and you should see it in your widget.

            tip: don't forget to save your qrc file after making changes to it.

            Qt Certified Specialist
            www.edalsolutions.be

            1 Reply Last reply
            0
            • S Offline
              S Offline
              saobien39
              wrote on last edited by
              #6

              Thanks so much :)

              1 Reply Last reply
              0
              • EddyE Offline
                EddyE Offline
                Eddy
                wrote on last edited by
                #7

                You're welcome.

                If your issue is solved please add [solved] to the title of this topic by editing your first post. Thanks.

                Qt Certified Specialist
                www.edalsolutions.be

                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