Custom Qt Widgets with python for Qt Designer

怎甘沉沦 提交于 2019-12-04 09:31:16

问题


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?

回答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




回答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




回答3:


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.



来源:https://stackoverflow.com/questions/16030170/custom-qt-widgets-with-python-for-qt-designer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!