使用 qtdesigner 为 PyQt4 稍微定制的小部件 [英] slightly customized widget for PyQt4 with qtdesigner

查看:38
本文介绍了使用 qtdesigner 为 PyQt4 稍微定制的小部件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 PyQt4 创建一个应用程序,我想使用 qtDesigner 来设计布局.该应用程序包含一个 QGraphicView,我想为其实现每个鼠标的平移和缩放.我知道如何做到这一点的唯一方法是从 QGraphicView 覆盖鼠标*"功能来进行平移和缩放.

I am creating an application with PyQt4 and I want to use qtDesigner to design the layout. The application contains a QGraphicView, for which I want to implement panning and zomming per mouse. The only way I know how to do that is deriving from QGraphicView overwriting the "mouse*" functions to do the panning and zooming.

现在我想在 qtdesigner 中使用这个新的自定义小部件.

Now I want to use this new custom widget with qtdesigner.

谷歌搜索我发现我可以为 qtdesigner 编写一个自定义小部件插件".虽然看起来并不难,但我仍然觉得我想要做的这么小的调整有点矫枉过正.

googling I find that I could write a "custom widget plugin" for qtdesigner. While it does not seem to be to difficult, I still find it overkill for such a little adjustment I want to make.

在使用 qdesigner 完成布局后,还有哪些其他方法可以在 PyQt4 中自定义小部件?

What other ways are there to customize a widget in PyQt4 when the layout is done with qdesigner?

谢谢!

推荐答案

你可以将你的 QGraphicsView 提升为你自己的子类在设计器中,右键单击 QGraphicsView 并选择Promote To"并在对话框中填写有关您自己的子类的相关信息:

You can promote your QGraphicsView to your own subclass In the designer, right click on the QGraphicsView and select "Promote To" and fill the dialog with relevant information about your own subclass:

这篇关于使用 qtdesigner 为 PyQt4 稍微定制的小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆