Creating a resource file to use it in Qt Designer
Asked Answered
B

3

13

I want to add a background image to a widget and thus I need a resource file but I am not able to create it in Qt Designer. Here is what I did:

  1. From the widget I go to the resources browser and click on the "add new file" button then a new window pops up.

  2. I am asked to point to the .qrc file but this file does not exist and I don't know how to create it.

I googled and found that .qrc files are created using Qt Creator.

Can't I create a .qrc file in Qt Designer ? Do I need to use Qt Creator to create a .qrc file and then use it in QT Designer ?

I am using Qt Designer with PyQt in CentOS 7.0

Biskra answered 22/10, 2014 at 13:7 Comment(0)
S
4

I would use Qt Creator, since Qt Designer is built in and you can simply create resource files. However, if that's not possible for you, here's a simple qrc data file contents that you can use: -

<RCC>
    <qresource prefix="/images">
    </qresource>
</RCC>

It creates a prefix called "/images/", ready to add images to the resource. Just create a file with .qrc extension and add that.

Sloatman answered 22/10, 2014 at 13:11 Comment(4)
I created a file named np.qrc that has the code you provided and loaded in to resource but there is no prefix created.Biskra
Does the file load when you open it and can you edit it from there?Sloatman
I was making some stupid mistake. Its done thanks a ton. Can you tell me how to install QT Creator on Centos 7.0. I have tried the following: yum install qt-creator and also I tried to install it by yum install qt..BTW thanks a lot for your help.Biskra
Download it from here: qt-project.org/downloads Click on "Show Downloads" at the bottom of the page and then scroll down to the section for Qt Creator. There's a 32 and 64-bit version, as well as the source code.Sloatman
T
12

You only need Qt Designer, and it can be done very easily, like this:

  1. Open the Resource Browser (View -> Resource Browser)
  2. Click the Edit Resources button (first on the left)
  3. Click the New Resource File button (first on the left)
  4. Enter a file name (e.g. resources.qrc) and click Save
  5. Click the Add Prefix button (fourth from the left) and enter a name (e.g. images)
  6. Click the Add Files button (fifth from the left) and add your resources
Tribble answered 22/10, 2014 at 16:8 Comment(0)
B
11

Using Qt Creator.

(Using the Qt Designer that is inside of Qt creator)

  1. Right clicking on your project
  2. Add new
  3. Step on the left option QT
  4. Qt Resource file
  5. Follow the wizard to add one

I took those instructions from the video QT Resource Files

Burnette answered 10/1, 2017 at 20:56 Comment(0)
S
4

I would use Qt Creator, since Qt Designer is built in and you can simply create resource files. However, if that's not possible for you, here's a simple qrc data file contents that you can use: -

<RCC>
    <qresource prefix="/images">
    </qresource>
</RCC>

It creates a prefix called "/images/", ready to add images to the resource. Just create a file with .qrc extension and add that.

Sloatman answered 22/10, 2014 at 13:11 Comment(4)
I created a file named np.qrc that has the code you provided and loaded in to resource but there is no prefix created.Biskra
Does the file load when you open it and can you edit it from there?Sloatman
I was making some stupid mistake. Its done thanks a ton. Can you tell me how to install QT Creator on Centos 7.0. I have tried the following: yum install qt-creator and also I tried to install it by yum install qt..BTW thanks a lot for your help.Biskra
Download it from here: qt-project.org/downloads Click on "Show Downloads" at the bottom of the page and then scroll down to the section for Qt Creator. There's a 32 and 64-bit version, as well as the source code.Sloatman

© 2022 - 2024 — McMap. All rights reserved.