创建资源文件以在 Qt Designer 中使用它 [英] Creating a resource file to use it in Qt Designer
问题描述
我想向小部件添加背景图像,因此我需要一个资源文件,但我无法在 Qt Designer 中创建它.这是我所做的:
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:
我从小部件转到资源浏览器,然后单击添加新文件"按钮,然后弹出一个新窗口.
From the widget I go to the resources browser and click on the "add new file" button then a new window pops up.
我被要求指向 .qrc 文件,但该文件不存在,我不知道如何创建它.
I am asked to point to the .qrc file but this file does not exist and I don't know how to create it.
我在谷歌上搜索并发现 .qrc 文件是使用 Qt Creator 创建的.
I googled and found that .qrc files are created using Qt Creator.
我不能在 Qt Designer 中创建 .qrc 文件吗?我是否需要使用 Qt Creator 创建一个 .qrc 文件,然后在 QT Designer 中使用它?
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 ?
我在 CentOS 7.0 中使用 Qt Designer 和 PyQt
I am using Qt Designer with PyQt in CentOS 7.0
推荐答案
我会使用 Qt Creator,因为 Qt Designer 是内置的,您可以简单地创建资源文件.但是,如果这对您来说是不可能的,那么您可以使用以下简单的 qrc 数据文件内容:-
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>
它创建了一个名为/images/"的前缀,准备将图像添加到资源中.只需创建一个扩展名为 .qrc 的文件并添加它.
It creates a prefix called "/images/", ready to add images to the resource. Just create a file with .qrc extension and add that.
这篇关于创建资源文件以在 Qt Designer 中使用它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!