[Qt-interest] Sanity check on using dynamic_cast<> with Qt
K. Frank
kfrank29.c at gmail.com
Tue May 11 03:38:40 CEST 2010
Alex -
Thanks.
On Mon, May 10, 2010 at 8:25 PM, Malyushytsky, Alex <alex at wai.com> wrote:
> Check documentation for:
>
> T qobject_cast ( QObject * object )
I gave this a try (I simply replaced "dynamic_cast" with
"qobject_cast" in my example,
below.), and it looks like it works fine.
Quoting from the documentation:
[qobject_cast] doesn't require RTTI support and it works across
dynamic library boundaries.
Am I correct, therefore, that qobject_cast should be more portable
than dynamic_cast
across the platforms on which Qt runs?
K. Frank
> Regards,
> Alex
>
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of K. Frank
>
> Hello List -
>
> I get a QWidget* out of a QTableWidget cell and I need to cast it to
> derived type.
> ...
> I need to access the value() member function of my RadioBox class, and I do so
> as follows:
>
> int value = dynamic_cast<RadioBox*>(tableWidget->cellWidget (row,
> column))->value();
>
> Is this the preferred Qt way of doing this?
> ...
> K. Frank
More information about the Qt-interest-old
mailing list