[Qt-interest] qobject_cast<> questions

Ross Bencina rossb-lists at audiomulch.com
Sat May 30 12:16:55 CEST 2009


Hi everyone

Does anyone know exactly when qobject_cast is needed and why (ie where 
dynamic_cast will crash)?  Is it only when using dynamically loaded plugins, 
or can it happen with any use of Qt as a shared library such as using the 
standard Qt DLLs and Frameworks from Qt Software (i'm on Win32 and OSX)?

The documentation is kind of vague, and I generally use dynamic_cast (which 
generally works) but I'm wondering if I have any latent bugs waiting to 
happen.

Also, can I rely on qobject_cast<> to work with null pointers? (ie to return
null if it is passed null?)

Thanks!

Ross.




More information about the Qt-interest-old mailing list