Results 1 to 3 of 3

Thread: Resource Problem?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2010
    Posts
    107
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Angry Resource Problem?

    I have a Qlable that I want to set a picture to. I want the picture to be embedded in the executable. I am using Creator to build this app. I think I might be creating the resource file incorrectly. From my searching to do what I want, the steps are:
    1. Create a .qrc file with the files you want included.
    2. Reference your .qrc file in the .pro file
    3. then you should be able to access the files and they will be embedded.

    So I created a .qrc file. I used notepad and indicated the file and saved it as graphics.qrc
    Qt Code:
    1. <RCC>
    2. <qresource>
    3. <file> MainPic.jpg </file>
    4. </qresource>
    5. </RCC>
    To copy to clipboard, switch view to plain text mode 
    The picture is in the same folder as the graphics.qrc file
    Then in my .pro file I added
    RESOURCES = graphics.qrc

    When I build I get an error: [debug/qrc_mxtrainer.cpp] Error 1

    What am I doing wrong?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Resource Problem?

    please post the real error message where it says what wrong. Have you also a qrc named mxtrainer?

  3. #3
    Join Date
    Aug 2010
    Posts
    107
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Resource Problem?

    OOPS, I typed in the code as an example but not the actual code, the actual RESOURCES line read RESOURCES = mxtrainer.qrc. But I seemed to have found the problem. Here is what worked for me in case anyone else is having the same problem. In Creator you have to go to "file"/"New File or Project"/QT/QT Resource File and create your resource file there. I had to then add a prefix...it entered "/new/prefix1" by default and then you can add files. I could not find any documentation on this part of Creator. You can keep adding prefixes and it adds /new/prefix2... /new/prefix3. What is the purpose the index and why different indexes? After the resource is added you can just go to the QLable properties and set the pixmap to the file you want...Not too difficult if you know how it is done...but difficult if you don't know all the steps! Is this the proper way to do this or is there a better way?

Similar Threads

  1. Resource dispose in Qt4
    By tpieciak in forum Qt Programming
    Replies: 4
    Last Post: 12th September 2010, 23:51
  2. problem about load resource file dynamically
    By Raul in forum Qt Programming
    Replies: 1
    Last Post: 27th August 2010, 05:56
  3. resource file name problem in generated code
    By acpRobert in forum Qt Tools
    Replies: 0
    Last Post: 26th April 2009, 02:06
  4. Replies: 2
    Last Post: 14th January 2008, 18:09
  5. QTextDocument Image resource problem
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 16th August 2007, 15:28

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.