本文整理汇总了C++中QLibrary类的典型用法代码示例。如果您正苦于以下问题:C++ QLibrary类的具体用法?C++ QLibrary怎么用?C++ QLibrary使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QLibrary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QFileInfo
QLibrary* RazorPluginInfo::loadLibrary(const QString& libDir) const
{
QString baseName, path;
QFileInfo fi = QFileInfo(fileName());
path = fi.canonicalPath();
baseName = value("X-Razor-Library", fi.completeBaseName()).toString();
QString soPath = QString("%1/lib%2.so").arg(libDir, baseName);
QLibrary* library = new QLibrary(soPath);
if (!library->load())
{
qWarning() << QString("Can't load plugin lib \"%1\"").arg(soPath) << library->errorString();
delete library;
return 0;
}
QString locale = QLocale::system().name();
QTranslator* translator = new QTranslator(library);
translator->load(QString("%1/%2/%2_%3.qm").arg(path, baseName, locale));
qApp->installTranslator(translator);
return library;
}
示例2: load
bool load(const char* dllname)
{
if (library(dllname)) {
DBG("'%s' is already loaded\n", dllname);
return true;
}
std::list<std::string> libnames = sLibNamesMap[dllname];
if (libnames.empty())
libnames.push_back(dllname);
std::list<std::string>::const_iterator it;
QLibrary *dll = new QLibrary();
for (it = libnames.begin(); it != libnames.end(); ++it) {
dll->setFileName((*it).c_str());
if (dll->load())
break;
DBG("%s\n", dll->errorString().toLocal8Bit().constData()); //why qDebug use toUtf8() and printf use toLocal8Bit()?
}
if (it == libnames.end()) {
DBG("No dll loaded\n");
delete dll;
return false;
}
DBG("'%s' is loaded~~~\n", dll->fileName().toUtf8().constData());
sDllMap[dllname] = dll; //map.insert will not replace the old one
return true;
}
示例3: setSafeMode
/**
* \brief Load a OPluginItem for the specified interface
* This will open the resource of the OPluginItem::path() and then will query
* if the Interface specified in the uuid is available and then will manage the
* resource and Interface.
*
* @param item The OPluginItem that should be loaded
* @param uuid The Interface to query for
*
* @return Either 0 in case of failure or the Plugin as QUnknownInterface*
*/
QUnknownInterface* OGenericPluginLoader::load( const OPluginItem& item, const QUuid& uuid) {
/*
* Check if there could be a library
*/
QString pa = item.path();
if ( pa.isEmpty() )
return 0l;
/*
* See if we get a library
* return if we've none
*/
setSafeMode( pa, true );
QLibrary *lib = Internal::OPluginLibraryHolder::self()->ref( pa );
if ( !lib ) {
setSafeMode();
return 0l;
}
/**
* try to load the plugin and just in case initialize the pointer to a pointer again
*/
QUnknownInterface* iface=0;
if ( lib->queryInterface( uuid, &iface ) == QS_OK ) {
installTranslators( item.name() );
m_library.insert( iface, lib );
}else
iface = 0;
setSafeMode();
return iface;
}
示例4: error
bool
FirebirdDriver::initialize()
{
if (_library != NULL)
return true;
FirebirdConfig config;
if (!config.load())
return error("Can't read firebird.cfg file");
// Set firebird install directory
#ifdef WIN32
SetEnvironmentVariable("INTERBASE", parseDir(config.installDir));
SetEnvironmentVariable("FIREBIRD", parseDir(config.installDir));
#else
setenv("INTERBASE", parseDir(config.installDir), true);
setenv("FIREBIRD", parseDir(config.installDir), true);
#endif
// Try to load the library
QLibrary* library = new QLibrary(config.library);
if (!library->load()) {
libraryError();
delete library;
return error("Can't load firebird library: " + config.library);
}
_library = library;
_procs = new FirebirdProcs(_library);
return true;
}
示例5: defined
Garmin::IDevice * CDeviceGarmin::getDevice()
{
Garmin::IDevice * (*func)(const char*) = 0;
Garmin::IDevice * dev = 0;
#if defined(Q_OS_MAC)
// MacOS X: plug-ins are stored in the bundle folder
QString libname = QString("%1/lib%2" XSTR(SHARED_LIB_EXT))
.arg(QCoreApplication::applicationDirPath().replace(QRegExp("MacOS$"), "Resources/Drivers"))
.arg(devkey);
#else
QString libname = QString("%1/lib%2" XSTR(SHARED_LIB_EXT)).arg(XSTR(PLUGINDIR)).arg(devkey);
#endif
QString funcname = QString("init%1").arg(devkey);
QLibrary lib;
lib.setFileName(libname);
bool lib_loaded = lib.load();
if (lib_loaded)
{
func = (Garmin::IDevice * (*)(const char*))lib.resolve(funcname.toLatin1());
}
if(!lib_loaded || func == 0)
{
QMessageBox warn;
warn.setIcon(QMessageBox::Warning);
warn.setWindowTitle(tr("Error ..."));
warn.setText(tr("Failed to load driver."));
warn.setDetailedText(lib.errorString());
warn.setStandardButtons(QMessageBox::Ok);
warn.exec();
return 0;
}
dev = func(INTERFACE_VERSION);
if(dev == 0)
{
QMessageBox warn;
warn.setIcon(QMessageBox::Warning);
warn.setWindowTitle(tr("Error ..."));
warn.setText(tr("Driver version mismatch."));
QString detail = QString(
tr("The version of your driver plugin \"%1\" does not match the version QLandkarteGT expects (\"%2\").")
).arg(libname).arg(INTERFACE_VERSION);
warn.setDetailedText(detail);
warn.setStandardButtons(QMessageBox::Ok);
warn.exec();
func = 0;
}
if(dev)
{
dev->setPort(port.toLatin1());
dev->setGuiCallback(GUICallback,this);
}
return dev;
}
示例6: supportsTransaction
bool QgsTransaction::supportsTransaction( const QgsVectorLayer* layer )
{
QLibrary* lib = QgsProviderRegistry::instance()->providerLibrary( layer->providerType() );
if ( !lib )
return false;
return lib->resolve( "createTransaction" );
}
示例7: resolveFunction
static T resolveFunction(QLibrary &lib, const char *name)
{
T temp = reinterpret_cast<T>(lib.resolve(name));
if (temp == nullptr) {
throw std::runtime_error(QObject::tr("invalid 7-zip32.dll: %1").arg(lib.errorString()).toLatin1().constData());
}
return temp;
}
示例8: c
QHSWidgetImpl::~QHSWidgetImpl()
{
delete iHsWidgetPublisher;
const QObjectList& c(children());
foreach (QObject* child, c)
{
QLibrary* lib = qobject_cast<QLibrary*> (child);
if (lib) lib->unload();
}
示例9: load
bool load()
{
m_libUdev.setLoadHints(QLibrary::ResolveAllSymbolsHint);
m_libUdev.setFileNameAndVersion(QStringLiteral("udev"), 1);
m_loaded = m_libUdev.load();
if (resolveMethods())
return true;
m_libUdev.setFileNameAndVersion(QStringLiteral("udev"), 0);
m_loaded = m_libUdev.load();
return resolveMethods();
}
示例10: eCompass_GetVersion
//eComnpass libray funcitons
void eCompass_GetVersion(int *pMajorVer, int *pMinorVer)
{
if(eCompass.isLoaded())
{
pFuncGetVersion eCompass_GetVersion = (pFuncGetVersion) eCompass.resolve("eCompass_GetVersion");
if(eCompass_GetVersion)
{
eCompass_GetVersion(pMajorVer, pMinorVer);
}
}
}
示例11: SND_Stop
BOOL SND_Stop(void)
{
if(Nordic.isLoaded())
{
pFuncGetBool SND_Stop = (pFuncGetBool)Nordic.resolve("SND_Stop");
if(SND_Stop)
{
return SND_Stop();
}
}
return FALSE;
}
示例12: NOR_Close
BOOL NOR_Close(void)
{
if(Nordic.isLoaded())
{
pFuncGetBool NOR_Close = (pFuncGetBool)Nordic.resolve("NOR_Close");
if(NOR_Close)
{
return NOR_Close();
}
}
return FALSE;
}
示例13: SND_Start
BOOL SND_Start(void)
{
if(Nordic.isLoaded())
{
pFuncGetBool SND_Start = (pFuncGetBool)Nordic.resolve("SND_Start");
if(SND_Start)
{
return SND_Start();
}
}
return FALSE;
}
示例14: SND_SendTxBuf
BOOL SND_SendTxBuf(UCHAR *ucTxBuf)
{
if(Nordic.isLoaded())
{
pFuncGetBoolParamUCharPt SND_SendTxBuf = (pFuncGetBoolParamUCharPt)Nordic.resolve("SND_SendTxBuf");
if(SND_SendTxBuf)
{
return SND_SendTxBuf(ucTxBuf);
}
}
return FALSE;
}
示例15: RTK_GetRxBuf
UCHAR* RTK_GetRxBuf(void)
{
if(Nordic.isLoaded())
{
pFuncGetUCHARPt RTK_GetRxBuf = (pFuncGetUCHARPt)Nordic.resolve("RTK_GetRxBuf");
if(RTK_GetRxBuf)
{
return RTK_GetRxBuf();
}
}
return NULL;
}