本文整理汇总了C++中QObject::qt_metacast方法的典型用法代码示例。如果您正苦于以下问题:C++ QObject::qt_metacast方法的具体用法?C++ QObject::qt_metacast怎么用?C++ QObject::qt_metacast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QObject
的用法示例。
在下文中一共展示了QObject::qt_metacast方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
void QAudioPluginLoader::load()
{
if (!m_plugins.isEmpty())
return;
QStringList plugins = pluginList();
for (int i=0; i < plugins.count(); i++) {
QPluginLoader* loader = new QPluginLoader(plugins.at(i));
QObject *o = loader->instance();
if (o != 0 && o->qt_metacast(m_iid) != 0)
m_plugins.append(loader);
else {
qWarning() << "QAudioPluginLoader: Failed to load plugin: "
<< plugins.at(i) << loader->errorString();
}
}
}
示例2: QDeclarativeComponent
//.........这里部分代码省略.........
QObject *obj = stack.pop();
QDeclarativePropertyValueInterceptor *vi = reinterpret_cast<QDeclarativePropertyValueInterceptor *>(reinterpret_cast<char *>(obj) + instr.assignValueInterceptor.castValue);
QObject *target = stack.at(stack.count() - 1 - instr.assignValueInterceptor.owner);
QDeclarativeProperty prop =
QDeclarativePropertyPrivate::restore(datas.at(instr.assignValueInterceptor.property), target, ctxt);
obj->setParent(target);
vi->setTarget(prop);
QDeclarativeVMEMetaObject *mo = static_cast<QDeclarativeVMEMetaObject *>((QMetaObject*)target->metaObject());
mo->registerInterceptor(prop.index(), QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), vi);
}
break;
case QDeclarativeInstruction::StoreObjectQList:
{
QObject *assign = stack.pop();
const ListInstance &list = qliststack.top();
list.qListProperty.append((QDeclarativeListProperty<void>*)&list.qListProperty, assign);
}
break;
case QDeclarativeInstruction::AssignObjectList:
{
// This is only used for assigning interfaces
QObject *assign = stack.pop();
const ListInstance &list = qliststack.top();
int type = list.type;
void *ptr = 0;
const char *iid = QDeclarativeMetaType::interfaceIId(type);
if (iid)
ptr = assign->qt_metacast(iid);
if (!ptr)
VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot assign object to list"));
list.qListProperty.append((QDeclarativeListProperty<void>*)&list.qListProperty, ptr);
}
break;
case QDeclarativeInstruction::StoreVariantObject:
{
QObject *assign = stack.pop();
QObject *target = stack.top();
CLEAN_PROPERTY(target, instr.storeObject.propertyIndex);
QVariant v = QVariant::fromValue(assign);
void *a[] = { &v, 0, &status, &flags };
QMetaObject::metacall(target, QMetaObject::WriteProperty,
instr.storeObject.propertyIndex, a);
}
break;
case QDeclarativeInstruction::StoreInterface:
{
QObject *assign = stack.pop();
QObject *target = stack.top();
CLEAN_PROPERTY(target, instr.storeObject.propertyIndex);
int coreIdx = instr.storeObject.propertyIndex;
QMetaProperty prop = target->metaObject()->property(coreIdx);
int t = prop.userType();
const char *iid = QDeclarativeMetaType::interfaceIId(t);
bool ok = false;
示例3: file
//.........这里部分代码省略.........
#if __REQUIRED_RPCNDR_H_VERSION__ < Q_REQUIRED_RPCNDR_H_VERSION
out << "\t** Required version of MIDL could not be verified. QRect, QSize and QPoint" << endl;
out << "\t** support needs an updated Platform SDK to be installed." << endl;
out << "\t*************************************************************************" << endl;
#else
out << "\t************************************************************************/" << endl;
#endif
out << endl;
out << "\t[uuid(" << idQRect << ")]" << endl;
out << "\tstruct QRect {" << endl;
out << "\t\tint left;" << endl;
out << "\t\tint top;" << endl;
out << "\t\tint right;" << endl;
out << "\t\tint bottom;" << endl;
out << "\t};" << endl << endl;
out << "\t[uuid(" << idQSize << ")]" << endl;
out << "\tstruct QSize {" << endl;
out << "\t\tint width;" << endl;
out << "\t\tint height;" << endl;
out << "\t};" << endl << endl;
out << "\t[uuid(" << idQPoint << ")]" << endl;
out << "\tstruct QPoint {" << endl;
out << "\t\tint x;" << endl;
out << "\t\tint y;" << endl;
out << "\t};" << endl;
#if __REQUIRED_RPCNDR_H_VERSION__ < Q_REQUIRED_RPCNDR_H_VERSION
out << "\t*/" << endl;
#endif
out << endl;
out << "\t/* Forward declaration of classes that might be used as parameters */" << endl << endl;
int res = S_OK;
for (const QString &className : keys) {
const QMetaObject *mo = qAxFactory()->metaObject(className);
// We have meta object information for this type. Forward declare it.
if (mo) {
QByteArray cleanType = qax_clean_type(className, mo).toLatin1();
out << "\tcoclass " << cleanType << ';' << endl;
subtypes.append(cleanType);
if (!QMetaType::type(cleanType))
qRegisterMetaType<void *>(cleanType);
cleanType += '*';
subtypes.append(cleanType);
if (!QMetaType::type(cleanType))
qRegisterMetaType<void *>(cleanType);
}
}
out << endl;
for (const QString &className : keys) {
const QMetaObject *mo = qAxFactory()->metaObject(className);
// We have meta object information for this type. Define it.
if (mo) {
QObject *o = qAxFactory()->createObject(className);
// It's not a control class, so it is actually a subtype. Define it.
if (!o)
res = classIDL(0, mo, className, false, out);
delete o;
}
}
out << endl;
if (res != S_OK)
goto ErrorInClass;
for (const QString &className : keys) {
QObject *o = qAxFactory()->createObject(className);
if (!o)
continue;
const QMetaObject *mo = o->metaObject();
QAxBindable *bind = static_cast<QAxBindable *>(o->qt_metacast("QAxBindable"));
bool isBindable = bind != 0;
const QByteArray cleanType = qax_clean_type(className, mo).toLatin1();
subtypes.append(cleanType);
subtypes.append(cleanType + '*');
res = classIDL(o, mo, className, isBindable, out);
delete o;
if (res != S_OK)
break;
}
out << "};" << endl;
out.flush();
ErrorInClass:
if (delete_qApp)
delete qApp;
if (res != S_OK) {
file.close();
file.remove();
}
return res;
}