Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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? What is the promoted class name?

Promote widget

like image 940
Ciasto piekarz Avatar asked Oct 27 '13 18:10

Ciasto piekarz


People also ask

Can you use Qt Designer with Pyside?

PySide2 Tutorial — Creating applications with Qt Designer The good news is that Qt comes with a graphical editor — Qt Designer — which contains a drag-and-drop UI editor. Using Qt Designer you can define your UIs visually and then simply hook up the application logic later.

How do I add a widget to Qt?

Note: The UI text in Qt Creator and the contents of the generated files depend on the Qt Creator version that you use. To create the Notepad project, select File > New Project > Application (Qt) > Qt Widgets Application > Choose, and follow the instructions of the wizard.

How do I run a qt5 designer?

How to Start the PyQt5 Designer tool. Go to C:\Program Files (x86)\Python36-32\Lib\site-packages\pyqt5-tools and locate designer.exe . Double click to open the Qt Designer. Note: The path will vary based on the OS you're using.


1 Answers

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.

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

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

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

like image 117
mata Avatar answered Oct 13 '22 13:10

mata