当前位置: 首页>>代码示例>>C++>>正文


C++ QMetaMethod::getMetaObject方法代码示例

本文整理汇总了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;
}
开发者ID:wpbest,项目名称:copperspice,代码行数:72,代码来源:qobject.cpp


注:本文中的QMetaMethod::getMetaObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。