Kdevelop+QTDesigner problem

Andreas Pakulat apaku at gmx.de
Wed May 17 20:21:23 BST 2006


On 17.05.06 14:44:11, Victor Ramiro wrote:
> First of all, sorry for my poor english

I'v seen worse ;-)

> QWidget * form = getFormFromStackWidgets();  // supouse that form is a Form1
> object
> AbstractFormClass * aform = (AbstractFormClass *) form;

Uh, Oh, that really hurts my eyes. For QObject-derived classes you can
use qt_cast<>() for anything else you should use dynamic_cast<>() or
static_cast<>() (depending on the situation). Note that the last 2 need
RTTI support from your compiler, which should be available in any decent
one. qt_cast works always.

Using qt_cast and dynamic_cast also enable you to check wether the cast
really succeeded, if it doesn't aform is 0.

> Object* result = aform->method();   // dynamic binding to Form1::method
> 
> well, debugging i found that result is always NULL.
> Why?, method is never called. Instead, i entered to qt_cast from
> Form1.moc(why??, someone explain this to me...)
> Well, i think the problem is in qt_cast code:
> 
> void* QTGUI::FormGUICode::qt_cast( const char* clname )
> {
>    if ( !qstrcmp( clname, "GUI::Form1Code" ) )
>        return this;
>    if ( !qstrcmp( clname, "AbstractFormClass" ) )  // <-- here is wrong??
>        return (AbstractFormClass*)this;
>    return FormPRespuesta::qt_cast( clname );
> }

I'm not sure how good Qt3's support for namespaces is. Also I think
there might be something wrong with your declarations. Can you show us
the class declaration of your Form1Code and the top of your .ui file?

Andreas

-- 
Your best consolation is the hope that the things you failed to get weren't
really worth having.




More information about the KDevelop mailing list