You are right that you can't just assign a pyqtSignal to an instance. It
has to be a class attribute so that the metaclass can create the proper
plumbing under the hood. Though i am not exactly sure what you need without
seeing a bit more of the examples. Are they always QLineEdit widgets and is
connecting the signal part of your builder?
Multiple inheritance will solve the part about getting the signals onto the
objects, but not really solving the connections if they are all different
types.



On Wed, Oct 9, 2013 at 2:39 AM, Marcus Ottosson <[email protected]>wrote:

> I'm building widgets via a separate builder method and would like them all
> to get the same set of signals. So I tried
>
> from PyQt4.QtGui import *
> from PyQt4.QtCore import *
>
> if __name__ == '__main__':
> import sys
>
> app = QApplication(sys.argv)
>
> widget = QLineEdit()
> widget.mysignal = pyqtSignal(object)
> widget.mysignal.connect(widget.textChanged)
>
> widget.show()
>
> sys.exit(app.exec_())
>
>
> But I'm getting:
>
> AttributeError: 'PyQt4.QtCore.pyqtSignal' object has no attribute 'connect'
>
> So I suspect it may have something to do with pyqtSignal being a factory
> and that it may introspect the class in which it is usually called (to get
> it's name) but can't wrap my head around how to make it work in a builder,
> or to simply assign a signal to an object outside of it's constructor.
>
> Anyone encountered this? How would you rather solve this issue?
> Ultimately, I'm looking to avoid typing the 4-5 separate signals that I'd
> like all of my similar widgets to inherit. Is multiple inheritance a better
> way?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAuoev5qiHJn-h%3DeXQWbqAs%3DfZzjpVOFTT8SdbpCxyUCw%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA32B16N%2B7wPbEN%2BGA1A8eOstcaquxR9daW2m6uwXyWMog%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to