Search This Blog

Tuesday, June 30, 2009

Qt qobject_cast advantage

qobject_cast is like dynamic_cast; it can cast object inherits from QObject.
The advantage is qobject_cast does not require RTTI support

To use it, make sure Q_OBJECT macro is included. Or the return type is undefined.

StackedWidget *stackedWidget = qobject_cast(parent());
if(stackedWidget != 0)
//do something

No comments: