简体   繁体   English

如何在pyqt4中的Qt Designer中使用promote?

[英]How do I use promote to in Qt Designer in pyqt4?

In the designer when I right click a widget, and I click promote to I get this window. 在设计器中,当我右键单击一个小部件时,我点击提升到我得到这个窗口。 See the screenshot below. 请参见下面的截图。

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? 这是否意味着我可以在这种情况下创建一个新类,继承QLineEdit并为其添加更多方法? What is the promoted class name? 推广的班级名称是什么?

推广小部件

This allows you to use custom widgets defined elsewhere, which designer otherwise wouldn't know about. 这允许您使用其他地方定义的自定义小部件,而设计者则不知道这些小部件。

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 . 例如,如果您已经定义了一个从QLabel派生的小部件MyLabel ,那么您可以在此处定义它,然后只需在您的ui中插入一个QLabel作为占位符并将其提升为MyLabel

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 然后,uic编译器将包含必要的导入/包含,例如,如果您将mypackage/mycomponent.h指定为头文件而MyLabel为类名,则pyuic将添加

from mypackage.mycomponent import MyLabel

(note how the .h is ignored, and slashes are converted to . by pyuic to keep compatibility with python) (注意如何忽略.h ,斜杠转换为.由pyuic保持与python的兼容性)

Global include is ignored by pyuic, it only affects uic (generate #include "mypackage/mycomponent.h" or #include <mypackage/mycomponent.h> for c++) pyuic忽略全局包含 ,它只影响uic (为c ++生成#include "mypackage/mycomponent.h"#include <mypackage/mycomponent.h>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM