[PyQt] Protected methods in unwraped instances
nahuel.defosse at gmail.com
Thu Dec 30 14:38:22 GMT 2010
is there some way to detect weather a widget has been created from
Python (I belive through sip in the internals) and when it's been
created in C++.
I've come up with a very nasty solution that consists in checking for
a protected method and catching the RuntimeError. But I belive there
be something more clever.
tw = QTabWidget() # Is a PyQt object
te = QTextEdit()
sw = tw.parent() # -> <PyQt4.QtGui.QStackedWidget object at 0x93546ec>
RuntimeError: no access to protected functions or signals for objects
not created from Python
So, we came up with this code:
def is_sip_wrapped( foo ):
And do not feel comfortable with it at all, but it works. I guess
someone there could add some extra information about this detection.
Though I can perfectly call receivers for any other widget created in Python.
More information about the PyQt