ksrarc
23rd September 2009, 16:47
Hello,
Lets set this:
using namespace srps;
bool SRPSMain::initialize()
{
QObject * obj = new Species;
Species * sp = qobject_cast<Species*>( obj );
sp->setObjectName("sp");
qDebug() << obj << sp;
connect( sp, SIGNAL(destroyed()), this, SLOT(deleted()) );
sp->deleteLater();
return true;
}
void SRPSMain::deleted()
{
qDebug() << Q_FUNC_INFO << sender() << qobject_cast<Species*>( sender() );
}
both classes are QObject direct subclases and have Q_OBJECT macro.
the output is:
srps::Species(0x82ab00, name = "sp") srps::Species(0x82ab00, name = "sp")
void srps::SRPSMain::deleted() QObject(0x82ab00, name = "sp") QObject(0x0)
so, why the second qobject_cast does not work?
Thanks.
Lets set this:
using namespace srps;
bool SRPSMain::initialize()
{
QObject * obj = new Species;
Species * sp = qobject_cast<Species*>( obj );
sp->setObjectName("sp");
qDebug() << obj << sp;
connect( sp, SIGNAL(destroyed()), this, SLOT(deleted()) );
sp->deleteLater();
return true;
}
void SRPSMain::deleted()
{
qDebug() << Q_FUNC_INFO << sender() << qobject_cast<Species*>( sender() );
}
both classes are QObject direct subclases and have Q_OBJECT macro.
the output is:
srps::Species(0x82ab00, name = "sp") srps::Species(0x82ab00, name = "sp")
void srps::SRPSMain::deleted() QObject(0x82ab00, name = "sp") QObject(0x0)
so, why the second qobject_cast does not work?
Thanks.