Custom Qt Widgets with python for Qt Designer
Asked Answered
M

3

10

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?
Malone answered 16/4, 2013 at 6:28 Comment(0)
S
1

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

Swayder answered 20/5, 2014 at 23:15 Comment(8)
Nice, I am currently now working with Qt anymore. But this definitely answers my question! Thx for this late reply!Malone
Great! Just able to install it in Qt Designer: just make sure to add your path to custom widget into environment variables PYTHONPATH and PYQTDESIGNERPATH. And, I think we have to use Qt designer supplied by PyQt. I test it with Qt Designer from Qt C++ distribution, and it won't display my custom python qt widget.Swayder
Your link is broken, illustrating why you should always summarize the contents of a link, and just include it for reference.Overawe
Hm, pardon for that. Will note thisSwayder
That answer is not longer valid, the link is broken.Ers
As others have commented link is gone - no answer nowTube
Qt Designer? Don't you mean Qt Creator?Anxious
@PeterMortensen He meant Designer. But do you know a way to use QtCreator alongside PyQt ?Mcneil
O
2

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

Outstrip answered 16/4, 2013 at 18:14 Comment(3)
Thank you for this post, but unfortunately this does not answer my question. I am after a custom widget that is displayed in the designer itself without the need to add it "manually" within some code.Malone
can you elaborate along with an example, in your question you said "how to make a custom widget appear in other widget box", and thats what the post i wrote for you on my blog does, anyways, elaborate your problem with an example, will try to help you.Outstrip
I am talking about the Widget Box of the Qt Designer (link). The Widget Box lists all common widgets like buttons, lists etc. I want my custom widget to be displayed in that box so that I can add and work with my custom widget in the Qt Designer.Malone
I
2

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.

Iams answered 21/5, 2014 at 19:48 Comment(0)
S
1

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

Swayder answered 20/5, 2014 at 23:15 Comment(8)
Nice, I am currently now working with Qt anymore. But this definitely answers my question! Thx for this late reply!Malone
Great! Just able to install it in Qt Designer: just make sure to add your path to custom widget into environment variables PYTHONPATH and PYQTDESIGNERPATH. And, I think we have to use Qt designer supplied by PyQt. I test it with Qt Designer from Qt C++ distribution, and it won't display my custom python qt widget.Swayder
Your link is broken, illustrating why you should always summarize the contents of a link, and just include it for reference.Overawe
Hm, pardon for that. Will note thisSwayder
That answer is not longer valid, the link is broken.Ers
As others have commented link is gone - no answer nowTube
Qt Designer? Don't you mean Qt Creator?Anxious
@PeterMortensen He meant Designer. But do you know a way to use QtCreator alongside PyQt ?Mcneil

© 2022 - 2024 — McMap. All rights reserved.