我倒是有一个方案,不要使用connect 试图来创建你的槽函数。 QT有一个全局的QMetaObject::invokeMethod(this,actionMember,Qt::DirectConnection);
具体实现:void CGmRbmMenuBaseConfiger::slotActionResponse()
{
//warning : do not change any char....all RBM action call this function....
QAction *pClickedAction = dynamic_cast(sender());
QString strActionMember = pClickedAction->data().toString();
QByteArray arr (strActionMember.toLatin1());
const char* actionMember = arr.constData();
//invoke method member must slot function.
QObject *pInvokeObj= reinterpret_cast(m_pRbmMenu->property("InvokeObj").value());
bool b = QMetaObject::invokeMethod(m_pRbmResponser,actionMember,Qt::DirectConnection);
if(!b)//invoke method from "m_pActionResponser".
{
b = QMetaObject::invokeMethod(m_pActionResponser,actionMember,Qt::DirectConnection);
}
if(!b)
{
b =QMetaObject::invokeMethod(this,actionMember,Qt::DirectConnection);
}
if(!b && pInvokeObj != NULL)
{
b =QMetaObject::invokeMethod(pInvokeObj,actionMember,Qt::DirectConnection);
}
#ifndef NDEBUG
if(!b)
{
QMessageBox::information(NULL,"Invoked Method failed. ","slot function "+strActionMember+" connect failed ,check you function name.");
}
#endif
}