> Am 20.04.2017 um 08:05 schrieb nikita baryshnikov <nib952...@gmail.com>:
> 
> Hi, Igor
> 
> Your example is incorrect, cause you forget about Q_OBJECT macro in
> Channel class

That's what I just wanted to add as a general remark, because it is a common 
pitfall (at least for me): /every/ class which - directly or indirectly - 
inherits from QObject must have a Q_OBJECT declaration, /even/ if it doesn't 
emit or consume Qt signals or provides slots. IF that class is expected to 
behave nicely with said qobject_cast "and friends" (which is almost alway a 
desireable feature).

Q_OBJECT not only provides the glue to provide "slot" methods, but also 
generates the required meta information.

In fact, IIRC that's another advantage of qobject_cast over dynamic_cast: it 
works by design "across library boundaries" (dynamic_cast might or might not 
work, depending on whether the libraries share the same address space or other 
compiler-specific settings). 

Cheers,
  Oliver
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to