On Wed, 17 Mar 2010 11:31:50 -0700, Nathan Cournia <[email protected]> wrote: > Thanks for the reply. Perhaps you can tell me what's the best way to > handle > the following situation: > > // in C++ > class FooWidget: public QWidget > { > //... > void bar(); > //... > }; > > // the QWidget this function returns is more than likely a FooWidget > QWidget* getWidget(); > > In SIP, I wrap both FooWidget and getWidget. In Python, I do: > > # the returned C++ object is wrapped as a PyQt4.QtGui.QWidget, not a > FooWidget > a = getWidget(); > > # doesn't work, can't find method > a.bar() > > # crashed as of SIP 4.10 > b = sip.cast(a, FooWidget) > > # should work? > b.bar() > > Is this a good use of sip.cast or is there a better way to approach this > problem?
Implement %ConvertToSubClassCode for all your QObject subclasses. getWidget() will then return a FooWidget. Phil _______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
