分类:
2010-05-29 17:07:54
QByteArray tmp_signal_name;
// 得到元数据类
const QMetaObject *smeta =
sender->metaObject();
++signal; //skip code跳过信号标记,直接得到信号标识
//
得到信号的索引
int signal_index = smeta->indexOfSignal(signal);
if (signal_index < 0) {
// check for normalized
signatures
tmp_signal_name =
QMetaObject::normalizedSignature(signal).prepend(*(signal - 1));
signal = tmp_signal_name.constData() + 1;
signal_index =
smeta->indexOfSignal(signal);
if (signal_index < 0) {
return false;
}
}
QByteArray tmp_method_name;
int membcode = method[0] -
'0';
++method; // skip code
// 得到元数据类
const QMetaObject *rmeta =
receiver->metaObject();
int method_index = -1;
//
这里是一个case,信号即可以和信号连接也可以和槽连接
switch (membcode) {
case
QSLOT_CODE:
// 得到槽的索引
method_index =
rmeta->indexOfSlot(method);
break;
case
QSIGNAL_CODE:
// 得到信号的索引
method_index =
rmeta->indexOfSignal(method);
break;
}
if
(method_index < 0) {
// check for normalized methods
tmp_method_name = QMetaObject::normalizedSignature(method);
method = tmp_method_name.constData();
switch (membcode) {
case QSLOT_CODE:
method_index =
rmeta->indexOfSlot(method);
break;
case
QSIGNAL_CODE:
method_index =
rmeta->indexOfSignal(method);
break;
}
}
if (method_index < 0) {
return false;
}
int *types = 0;
if (type == Qt::QueuedConnection
&& !(types =
::queuedConnectionTypes(smeta->method(signal_index).parameterTypes())))
return false;
//
调用元数据类的连接
QMetaObject::connect(sender, signal_index, receiver,
method_index, type, types);
// 发送连接的通知,现在的实现是空的
const_cast
return true;
}