문제

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?
도움이 되었습니까?

해결책 3

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

다른 팁

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

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top