[PyQt] signal propagating

Eric Frederich eric.frederich at gmail.com
Tue Sep 28 22:00:13 BST 2010


Hello,

Here's a stripped down example of my problem.
I have a group of widgets that I keep together with a class called
MyWidgetGroup.
It holds a line edit and a label which together have a meaning (getMeaning)
but by themselves mean nothing.

I need to make connections to a method so it'll get called whenever the
widget's text changes but I don't want the reference to the line edit, I
want the reference to the widget group (so I can getMeaning on it).

To do this I wound up creating a dummy method that just propagates the
signal so that it comes from the widget group instead of just the line edit.
I have a bad feeling about this.  There must be a better way to do this
right?
Can this be accomplished by connecting signals to signals?

class MyWidgetGroup(QWidget):

    def __init__(self, parent=None):
        super(MyWidgetGroup, self).__init__(parent)

        self.myLabel = MyLabel(self)
        self.myEdit  = MyLineEdit(self)

        self.connect(self.myEdit,  SIGNAL("textChanged(QString)"),
self.pointless)

    def pointless(self, qstring):
        self.emit(SIGNAL("theValueChanged"))

    def getMeaning(self):
        return self.myLabel.text() + '-' + self.myEdit.text()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100928/03235cfd/attachment.html>


More information about the PyQt mailing list