[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] Bug in sip-4.11.1 and PyQt-4.7.7 ?
From:       Baz Walter <bazwal () ftml ! net>
Date:       2010-09-28 16:22:50
Message-ID: 4CA2165A.60409 () ftml ! net
[Download RAW message or body]

On 27/09/10 19:45, Gerard Vermeulen wrote:
>   Phil,
>
> when running the following code
>
> #!/usr/bin/env python
> # -*- coding: utf-8 -*-
>
> import PyQt4.Qt as Qt
>
> class MyWidget(Qt.QWidget):
>
>      def __init__(self, parent=None):
>          super(Qt.QWidget, self).__init__(parent)
>
>       # __init__()
>
> # class MyWidget
>
> def bar(widget):
>      pass
>
> # bar()
>
> def foo(widget):
>      print type(widget)
>      # BUG? For me widget is a Python type, but not for widget.connect().
>      widget.connect(widget, Qt.SIGNAL('item_changed(widget)'), bar)

"item_changed" is a new PyQt4 signal defined dynamically. so you need to 
write either:

   widget.connect(widget, Qt.SIGNAL('item_changed'), bar)

or possibly:

   widget.connect(widget, Qt.SIGNAL('item_changed(PyQt_PyObject)'), bar)

you would then emit "item_changed" like this:

   widget.emit(Qt.SIGNAL('item_changed'), widget)

or:

   widget.emit(Qt.SIGNAL('item_changed(PyQt_PyObject)'), widget)

see here for more details:

http://www.riverbankcomputing.com/static/Docs/PyQt4/pyqt4ref.html#pyqt-signals-and-qt-signals

> # foo()
>
> if __name__ == '__main__':
>      application = Qt.QApplication([])
>      widget = MyWidget()
>      foo(widget)
>
> # Local Variables: ***
> # mode: python ***
> # End: ***
>
> I get this traceback:
>
> <class '__main__.MyWidget'>
> Traceback (most recent call last):
>    File "bug.py", line 31, in<module>
>      foo(widget)
>    File "bug.py", line 23, in foo
>      widget.connect(widget, Qt.SIGNAL('item_changed(widget)'), bar)
> TypeError: C++ type 'widget' is not supported as a slot argument type
>
> but isn't widget a Python type? (although derived from a C++ type)

no. widget is an instance of class MyWidget, not a type.
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic