Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, April 2007
Qt/Mac Open Source qobject_cast problems?


Message 1 in thread

I'm running Qt/Mac Open Source, version 4.2.3 on OS X 10.4.9 and the  
latest version of XCode, etc. I installed the Qt binaries from ftp:// 
ftp.troll.no/qt/source.

I'm compiling a program we're developing on Linux as well. There  
seems to be some strange bits going on with a qobject_cast in our  
code that doesn't happen on Linux. I'm not sure if it's a bug, or  
where to go at this point.

Here's the code:
using namespace Avogadro;

bool LabelEngine::render()
{
   GLWidget *gl = qobject_cast<GLWidget *>(parent());
   if(!gl) {
     return false;
   }
  // further code here ...

OK, so LabelEngine is a plugin, and loaded by a factory class which  
sets parent to the GLWidget.

I checked parent() and it's non-NULL. In fact:
   parent()->metaObject()->className()

returns:
"Avogadro::GLWidget"

Correct! But the qobject_cast returns 0, so the // further code bits  
are never run and the function exits.

This happens on all render plugins -- there's a parent, the  
metaObject looks OK, but the qobject_cast fails.

Any suggestions where to start debugging?

Thanks,
-Geoff

--
 [ signature omitted ]