Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Qt Widgets with python for Qt Designer

I am trying to write a custom widget for the Qt Designer using only Python. I was following a couple of tutorials I found online but none of them were working or anything close to what I would call to be a minimum working example.

So my questions are:

  1. What steps are involved to make a a custom widget appear in the Widget Box of Qt Designer?
  2. If you can spare the time: Please provide a minimum working example (like a widget with a label in it saying "A truly minimal working Qt custom widget example").
  3. Or is it maybe not possible at all to include a custom widget using only python?
like image 748
Woltan Avatar asked Apr 16 '13 06:04

Woltan


People also ask

Does Qt designer work with Python?

To create a GUI for your windows and dialogs in PyQt, you can take two main paths: you can use Qt Designer, or you can hand code the GUI in plain Python code.

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.


3 Answers

There are very few examples available on how to make a custom widget in pyqt. I wrote this article with a working example: Making a Custom Widget in PyQt

like image 123
scottydelta Avatar answered Sep 20 '22 12:09

scottydelta


Here is the answer to your question #3: How do I use promote to in Qt Designer in pyqt4?

I am using PySide and it works the same way. This method works directly with your Python custom widget code. You do not need to write any separate plugin code.

After you have promoted your custom widget, you can right click on it and add your signals with "Change signals/slots..."

I would recommend putting all you widgets in a YourCostumWidgetsPack.UI file, and then when you load this file in Qt Designer, in addition to the UI you are working. It will load all your custom widget information.

like image 35
Tim S Avatar answered Sep 22 '22 12:09

Tim S


I found this article to be your answer: https://doc.qt.io/archives/qq/qq26-pyqtdesigner.html

But, I haven't been able to install it in Qt Designer though :D

like image 23
swdev Avatar answered Sep 18 '22 12:09

swdev