如何在pyqt4的Qt Designer中使用升级到? [英] How do I use promote to in Qt Designer in pyqt4?

查看:201
本文介绍了如何在pyqt4的Qt Designer中使用升级到?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在设计器中,当我右键单击小部件时,然后单击升级以得到此窗口。请参见下面的屏幕截图。

In the designer when I right click a widget, and I click promote to I get this window. See the screenshot below.

我从未使用过此功能。基本上,头文件使我感到困惑。这是为了什么这是否意味着我可以在这种情况下创建一个新类,继承QLineEdit并为其添加更多方法?升级的类名称是什么?

I have never used this feature. Basically, the header file is confusing me. What is it for? Does that mean I can create a new class in this case, inheriting QLineEdit and add more methods to it? What is the promoted class name?

推荐答案

这使您可以使用在其他地方定义的自定义窗口小部件,否则设计人员将不会知道。

This allows you to use custom widgets defined elsewhere, which designer otherwise wouldn't know about.

例如,如果您定义了从 QLabel 派生的小部件 MyLabel ,那么您可以在此处定义它,然后只需在用户界面中插入 QLabel 作为占位符,然后将其提升为 MyLabel

For example, if you've defined a widget MyLabel derived from QLabel, then you can define it here and then just insert a QLabel as placeholder in your ui and promote it to MyLabel.

然后uic编译器将包含必要的导入/包含,例如,如果您将 mypackage / mycomponent.h 指定为头文件和 MyLabel 作为类名,然后 pyuic 将添加

The uic compiler will then include the necessary imports/includes, for example if you specified mypackage/mycomponent.h as header file and MyLabel as class name, then pyuic will add

from mypackage.mycomponent import MyLabel

(请注意 .h 被忽略,斜线被pyuic转换为以保持与python的兼容性)

(note how the .h is ignored, and slashes are converted to . by pyuic to keep compatibility with python)

全局包含被pyuic忽略,它仅影响 uic (生成 #include mypackage / mycomponent.h #include< mypackage / mycomponent.h> for c ++)

Global include is ignored by pyuic, it only affects uic (generate #include "mypackage/mycomponent.h" or #include <mypackage/mycomponent.h> for c++)

这篇关于如何在pyqt4的Qt Designer中使用升级到?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆