[PyKDE] 'Casting' in PyQT

Phil Thompson phil at river-bank.demon.co.uk
Thu May 9 18:35:00 BST 2002


Robin Summerhill wrote:
> 
> Hi,
> 
> I'm guessing that the answer is 'no' but can I do something like the
> following:
> 
> myTextEdit = aWidget.child("TextEdit1")
> 
> (using the 'child' method of QObject inherited by QWidget - this returns a
> QObject* in C++)
> 
> and then use 'myTextEdit' as fully-fledged QTextEdit instance rather than a
> rather-feeble QObject instance (i.e. the equivalent of doing a
> dynamic_cast<QTextEdit*>(myTextEdit) in C++)

With v3.2 the type of myTextEdit will be QTextEdit rather than QObject.
If the QTextEdit wasn't created from Python (ie. it was created by Qt
internally) then you won't have access to any of its protected methods.

Phil




More information about the PyQt mailing list