[PyKDE] class name virtual function
Christian Bird
cbird at metrowerks.com
Fri Aug 22 00:59:01 BST 2003
Phil,
I've been working on a plugin system to use python widgets in designer. I was
wondering if you (or anyone else reading this) could help me out. One method
that is called a lot from within designer is QWidget->className(). All it is
supposed to do is return a string containing the name of the QWidget.
Apparently, there was some logic added to PyQt so that className would work
when called from within python even if the user didn't implement it for their
class.
example:
class SomeWidget(QWidget):
pass
sw = SomeWidget()
print sw.className() #prints out "SomeWidget" and not "QWidget"
Unfortunately, that same logic prevents python definitions of className in a
widget from being called from the C++ side of things. Other virtual
functions seem to work just fine. For example, if you define a new
paintEvent method on a python Widget then when the paintEvent is called from
the C++ side, the python method gets called. This is true for every virtual
function that I can find except for className.
example:
class SomeWidget(QWidget):
def className(self):
return "SomeWidget"
sw = SomeWidget()
passToCpp(sw)
in c++:
printf("className is %s\n", sw->className()); #this prints "QWidget"
What would I need to change in sip so that the className method is handled the
same as other virtual functions? Thanks a lot for your help.
-- Christian Bird
More information about the PyQt
mailing list