Yup that worked. Thanks much!

On Sun, Jan 22, 2012 at 6:50 PM, Joel B. Mohler <j...@kiwistrawberry.us> wrote:
> A requirement is that a class exposing signals is derived from QObject.
>  Note that QTreeView is (indirectly) derived from QObject so MySubClass
> meets that requirement.  I believe that the following will work:
>
> class MySubClass(QTreeView):
>    foo = Signal(int)
>
>
>    def __init__(self, parent = None):
>        QTreeView.__init__(self, parent)
>
>    def contextMenuEvent(self, event):
>        ...
>        self.foo.emit(42)
>        ...
>
> And then you use it with:
>
> def action(i):
>    print "tree context menu!!"
>
> tree=MySubClass()
> tree.foo.connect(action)
>
>
>
> On 01/22/2012 05:34 AM, Åke Kullenberg wrote:
>>
>> I want to add signals to a subclass I made of QTreeView. As per this
>> website (http://developer.qt.nokia.com/wiki/Signals_and_Slots_in_PySide),
>> I have a Communcate class that I instantiate in my QTreeView subclass.
>> Later on as the user right clicks in the QTreeView it will emit
>> signals as per the normal Qt philosophy.
>>
>> Is there any way to get rid of the Communicate class? Can I somehow
>> just add the signal straight to the QTreeView subclass, or is this the
>> way to do it?
>>
>> class Communicate(QObject):
>>     foo = Signal(int)
>>
>> class MySubClass(QTreeView):
>>     def __init__(self, parent = None):
>>         QTreeView.__init__(self, parent)
>>         self.c = Communicate()
>>     def contextMenuEvent(self, event):
>>         ...
>>         self.c.foo.emit(42)
>>         ...
>> _______________________________________________
>> PySide mailing list
>> PySide@lists.pyside.org
>> http://lists.pyside.org/listinfo/pyside
>
>
> _______________________________________________
> PySide mailing list
> PySide@lists.pyside.org
> http://lists.pyside.org/listinfo/pyside
_______________________________________________
PySide mailing list
PySide@lists.pyside.org
http://lists.pyside.org/listinfo/pyside

Reply via email to