View Full Version : Invoke a slot by its name in QString...
sunil.thaha
6th April 2006, 07:09
Hi,
Suppose there is a slot called a foo() in my DerivedFromQObject class;
I will have a QObject* ptr pointing to the DerivedFromQObject
I need to extract the Slots for the DerivedFromQObject's obj.
and ivoke its slot at run time. It's just like a plugin.
munna
6th April 2006, 07:33
Hi,
I wonder if you can do this.
jrideout
6th April 2006, 09:10
Try using
const QMetaObject * QObject::metaObject () const
Check out the docs for QMetaObject it should give you what you need
wysota
6th April 2006, 09:10
Hi,
Suppose there is a slot called a foo() in my DerivedFromQObject class;
I will have a QObject* ptr pointing to the DerivedFromQObject
I need to extract the Slots for the DerivedFromQObject's obj.
and ivoke its slot at run time. It's just like a plugin.
Dynamic signals and slots (http://doc.trolltech.com/qq/qq16-dynamicqobject.html)
jrideout
6th April 2006, 09:28
I haven't tried this but something like this might work:
DerivedObj * myDerivedObj = new myDerivedObj();
if (myDerivedObj->metaObject()->indexOfSlot( "slotName" ) != -1)
{
QMetaObject::invokeMethod ( myDerivedObj, "slotName", Qt::DirectConnection);
}
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.