本文整理汇总了C++中PluginInterface::pluginName方法的典型用法代码示例。如果您正苦于以下问题:C++ PluginInterface::pluginName方法的具体用法?C++ PluginInterface::pluginName怎么用?C++ PluginInterface::pluginName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PluginInterface
的用法示例。
在下文中一共展示了PluginInterface::pluginName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: relativePath
void tst_QPluginLoader::relativePath()
{
// Windows binaries run from release and debug subdirs, so we can't rely on the current dir.
const QString binDir = QFINDTESTDATA("bin");
QVERIFY(!binDir.isEmpty());
QCoreApplication::addLibraryPath(binDir);
QPluginLoader loader("theplugin");
loader.load(); // not recommended, instance() should do the job.
PluginInterface *instance = qobject_cast<PluginInterface*>(loader.instance());
QVERIFY(instance);
QCOMPARE(instance->pluginName(), QLatin1String("Plugin ok"));
QVERIFY(loader.unload());
}
示例2: listThePlugins
void tst_XQPluginLoader::listThePlugins()
{
QList<XQPluginInfo> plugins;
XQPluginLoader loader;
loader.listImplementations( tr( "xtheplugin.dll" ), plugins );
QVERIFY( plugins.count() != 0 );
for( int i( 0 ); i < plugins.count(); ++i ) {
loader.setUid( plugins[i ].uid() );
QCOMPARE( loader.load(), true );
PluginInterface *instance = qobject_cast<PluginInterface*>(loader.instance());
QCOMPARE(instance->pluginName(), QLatin1String("Plugin ok"));
QCOMPARE(loader.unload(), true);
}
plugins.clear();
}
示例3: reloadPlugin
void tst_QPluginLoader::reloadPlugin()
{
QPluginLoader loader;
loader.setFileName( sys_qualifiedLibraryName("theplugin")); //a plugin
loader.load(); // not recommended, instance() should do the job.
PluginInterface *instance = qobject_cast<PluginInterface*>(loader.instance());
QVERIFY(instance);
QCOMPARE(instance->pluginName(), QLatin1String("Plugin ok"));
QSignalSpy spy(loader.instance(), SIGNAL(destroyed()));
QVERIFY(spy.isValid());
QVERIFY(loader.unload()); // refcount reached 0, did really unload
QCOMPARE(spy.count(), 1);
// reload plugin
QVERIFY(loader.load());
QVERIFY(loader.isLoaded());
PluginInterface *instance2 = qobject_cast<PluginInterface*>(loader.instance());
QVERIFY(instance2);
QCOMPARE(instance2->pluginName(), QLatin1String("Plugin ok"));
QVERIFY(loader.unload());
}
示例4: errorString
//.........这里部分代码省略.........
#endif
QCOMPARE(obj, static_cast<QObject*>(0));
QCOMPARE(loader.errorString(), unknown);
bool unloaded = loader.unload();
#ifdef SHOW_ERRORS
qDebug() << loader.errorString();
#endif
QCOMPARE(unloaded, false);
QCOMPARE(loader.errorString(), unknown);
}
{
QPluginLoader loader( sys_qualifiedLibraryName("tst_qpluginloaderlib")); //not a plugin
bool loaded = loader.load();
#ifdef SHOW_ERRORS
qDebug() << loader.errorString();
#endif
QCOMPARE(loaded, false);
QVERIFY(loader.errorString() != unknown);
QObject *obj = loader.instance();
#ifdef SHOW_ERRORS
qDebug() << loader.errorString();
#endif
QCOMPARE(obj, static_cast<QObject*>(0));
QVERIFY(loader.errorString() != unknown);
bool unloaded = loader.unload();
#ifdef SHOW_ERRORS
qDebug() << loader.errorString();
#endif
QCOMPARE(unloaded, false);
QVERIFY(loader.errorString() != unknown);
}
{
QPluginLoader loader( sys_qualifiedLibraryName("nosuchfile")); //not a file
bool loaded = loader.load();
#ifdef SHOW_ERRORS
qDebug() << loader.errorString();
#endif
QCOMPARE(loaded, false);
QVERIFY(loader.errorString() != unknown);
QObject *obj = loader.instance();
#ifdef SHOW_ERRORS
qDebug() << loader.errorString();
#endif
QCOMPARE(obj, static_cast<QObject*>(0));
QVERIFY(loader.errorString() != unknown);
bool unloaded = loader.unload();
#ifdef SHOW_ERRORS
qDebug() << loader.errorString();
#endif
QCOMPARE(unloaded, false);
QVERIFY(loader.errorString() != unknown);
}
#if !defined Q_OS_WIN && !defined Q_OS_MAC && !defined Q_OS_HPUX && !defined Q_OS_SYMBIAN && !defined Q_OS_QNX
{
QPluginLoader loader( sys_qualifiedLibraryName("almostplugin")); //a plugin with unresolved symbols
loader.setLoadHints(QLibrary::ResolveAllSymbolsHint);
QCOMPARE(loader.load(), false);
#ifdef SHOW_ERRORS
qDebug() << loader.errorString();
#endif
QVERIFY(loader.errorString() != unknown);
QCOMPARE(loader.instance(), static_cast<QObject*>(0));
#ifdef SHOW_ERRORS
qDebug() << loader.errorString();
#endif
QVERIFY(loader.errorString() != unknown);
QCOMPARE(loader.unload(), false);
#ifdef SHOW_ERRORS
qDebug() << loader.errorString();
#endif
QVERIFY(loader.errorString() != unknown);
}
#endif
{
QPluginLoader loader( sys_qualifiedLibraryName("theplugin")); //a plugin
QCOMPARE(loader.load(), true);
QCOMPARE(loader.errorString(), unknown);
QVERIFY(loader.instance() != static_cast<QObject*>(0));
QCOMPARE(loader.errorString(), unknown);
// Make sure that plugin really works
PluginInterface* theplugin = qobject_cast<PluginInterface*>(loader.instance());
QString pluginName = theplugin->pluginName();
QCOMPARE(pluginName, QLatin1String("Plugin ok"));
QCOMPARE(loader.unload(), true);
QCOMPARE(loader.errorString(), unknown);
}
}