[Interest] qobject_cast

Thiago Macieira thiago.macieira at intel.com
Thu Apr 20 17:22:32 CEST 2017


Em quarta-feira, 19 de abril de 2017, às 22:56:46 PDT, Igor Mironchik 
escreveu:
> class Channel
> 
>    :  public QObject
> 
> {};

> void mySlot()
> {
>    Channel * ch = qobject_cast< Channel* > ( sender() );
>    // You are 100% sure that sender() is Channel!!!
>    // And this cast will fail!!!
> }

And so will dynamic_cast fail.

Fix it by adding a non-inline virtual destructor to Channel.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list