在 Qt Designer 中使用 PySide 自定义小部件

Using PySide custom widgets in Qt Designer

PyQt 有一个插件系统,用于向 Qt Designer 添加 python 小部件,以便可以将它们拖放到其他小部件的 .ui 文件中。

http://pyqt.sourceforge.net/Docs/PyQt4/designer.html#writing-qt-designer-plugins

PySide 小部件如何做到这一点?

  1. 将小部件的代码添加到项目 .pro 文件中。
  2. 从 Qt Designer 中选取一个 Widget 并将其放在窗体上。

  3. 右击它 select Promote to...

  4. 输入小部件的名称 class。

回答具体问题:"How could this be done for PySide widgets?"

曾经有一个 PySide 的 QtDesigner 插件允许在 python 中编写自定义小部件插件。然而,在它变得完全可行之前,它的开发就停止了。引用自 pyside 邮件列表:

On Thursday 24 March 2011 19:18:02 Hugo Parente Lima wrote:

On Wednesday 23 March 2011 22:46:32 Gerald Storer wrote:

I vote for removing the QtDesigner plugin example from pyside-examples, it doesn't work and the support for QtDesign plugins isn't on our roadmap yet, besides IMO it's not a very important feature to have and we have more urgent bugs and features to do at the moment.

Any objections?

超时!从 pyside-examples 存储库中删除了插件示例。

所以您所要做的就是找到旧的 QtDesigner 源代码,让它运行,然后提交必要的补丁:-)

你现在可以直接在PySide6提供的Qt Designer上使用Promote to...了。在Header file

中填入py文件名即可(没有.py扩展名)