本文整理汇总了C++中QMetaMethod::getMetaObject方法的典型用法代码示例。如果您正苦于以下问题:C++ QMetaMethod::getMetaObject方法的具体用法?C++ QMetaMethod::getMetaObject怎么用?C++ QMetaMethod::getMetaObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMetaMethod
的用法示例。
在下文中一共展示了QMetaMethod::getMetaObject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: disconnect
bool QObject::disconnect(const QObject *sender, const QMetaMethod &signalMethod,
const QObject *receiver, const QMetaMethod &slotMethod)
{
const QMetaObject *signalMetaObject = signalMethod.getMetaObject();
const QMetaObject *slotMetaObject = slotMethod.getMetaObject();
// run time checks
if (sender == 0) {
qWarning("QObject::disconnect() Can not disconnect as sender is null");
return false;
} else if (receiver == 0 && slotMetaObject != 0) {
qWarning("QObject::disconnect() Can not disconnect as receiver is null and slot was specified");
return false;
}
if (signalMetaObject) {
if (signalMethod.methodType() != QMetaMethod::Signal) {
qWarning("QObject::disconnect() Can not disconnect %s::%s, is not a signal",
sender->metaObject()->className(), signalMethod.signature());
return false;
}
}
if (slotMetaObject) {
if (slotMethod.methodType() == QMetaMethod::Constructor) {
qWarning("QObject::disconnect() Can not use constructor as an argument %s::%s",
receiver->metaObject()->className(), slotMethod.signature());
return false;
}
}
int signal_index = sender->metaObject()->indexOfSignal(signalMethod.signature());
// if signalMethod is not empty and signal_index is -1, then signal is not a member of sender
if (signalMetaObject != 0 && signal_index == -1) {
qWarning("QObject::disconnect() Signal %s was not found in class %s",
signalMethod.signature(), sender->metaObject()->className());
return false;
}
// method is not a member of receiver
if (receiver) {
int slot_index = receiver->metaObject()->indexOfMethod(slotMethod.signature());
if (slotMetaObject && slot_index == -1) {
qWarning("QObject::disconnect() Method %s was not found in class %s",
slotMethod.signature(), receiver->metaObject()->className());
return false;
}
}
const BentoAbstract *signal_Bento = signalMethod.getBentoBox();
const BentoAbstract *slot_Bento = slotMethod.getBentoBox();
if (! QObject::internal_disconnect(sender, signal_Bento, receiver, slot_Bento)) {
return false;
}
// calling the const char * (Qt4 API version)
if (signalMetaObject) {
const_cast<QObject*>(sender)->disconnectNotify(signalMethod.signature());
} else {
const_cast<QObject*>(sender)->disconnectNotify(0);
}
return true;
}