开发者

PyQT events between multiple objects

I am creating a GUI program in Python/PyQT and would like to know how I can connect an event which happens in a child object to the parent?

For example, if someone clicks a 'Submit' button, how would i trigger something to happen in the parent object (lets say update a QLabel on the pare开发者_Python百科nt)

Any help would be greatly appreciated

L


It is done like in C++ Qt by connecting signals to slots, you will find all the information on this page (and here for the old way).


You must connect these methods every time you set new parent (and remove old connections!!) http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qobject.html#connect (If widget parent change and You still wont that new parent to recive signals)

But if your layout is static just give good names for your widgets. Then connect each signal to callable (any python function) and that function will change QLable. In this case relation parent children change nothing since you refer to widgets by names not relations.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜