本文整理汇总了C++中QLibrary::load方法的典型用法代码示例。如果您正苦于以下问题:C++ QLibrary::load方法的具体用法?C++ QLibrary::load怎么用?C++ QLibrary::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLibrary
的用法示例。
在下文中一共展示了QLibrary::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resolveLibrary
static void resolveLibrary()
{
QLibrary lib;
#ifdef LIBRESOLV_SO
lib.setFileName(QStringLiteral(LIBRESOLV_SO));
if (!lib.load())
#endif
{
lib.setFileName(QLatin1String("resolv"));
if (!lib.load())
return;
}
local_dn_expand = dn_expand_proto(lib.resolve("__dn_expand"));
if (!local_dn_expand)
local_dn_expand = dn_expand_proto(lib.resolve("dn_expand"));
local_res_nclose = res_nclose_proto(lib.resolve("__res_nclose"));
if (!local_res_nclose)
local_res_nclose = res_nclose_proto(lib.resolve("res_9_nclose"));
if (!local_res_nclose)
local_res_nclose = res_nclose_proto(lib.resolve("res_nclose"));
local_res_ninit = res_ninit_proto(lib.resolve("__res_ninit"));
if (!local_res_ninit)
local_res_ninit = res_ninit_proto(lib.resolve("res_9_ninit"));
if (!local_res_ninit)
local_res_ninit = res_ninit_proto(lib.resolve("res_ninit"));
local_res_nquery = res_nquery_proto(lib.resolve("__res_nquery"));
if (!local_res_nquery)
local_res_nquery = res_nquery_proto(lib.resolve("res_9_nquery"));
if (!local_res_nquery)
local_res_nquery = res_nquery_proto(lib.resolve("res_nquery"));
}
示例2: 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();
}
示例3: loadLibrary
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;
}
示例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: initialize
void Converter::initialize()
{
initialized = true;
QLibrary libopencc;
libopencc.setFileNameAndVersion("opencc", "1.0.0");
if (!libopencc.load())
return;
opencc_open = (opencc_t (*)(const char *))libopencc.resolve("opencc_open");
if (opencc_open == NULL)
return;
opencc_close = (int (*)(opencc_t))libopencc.resolve("opencc_close");
if (opencc_close == NULL)
return;
opencc_convert_utf8 = (char * (*)(opencc_t, const char *, size_t))libopencc.resolve("opencc_convert_utf8");
if (opencc_convert_utf8 == NULL)
return;
opencc_errno = (opencc_error (*)(void))libopencc.resolve("opencc_errno");
if (opencc_errno == NULL)
return;
opencc_perror = (void (*)(const char *))libopencc.resolve("opencc_perror");
if (opencc_perror == NULL)
return;
s_loaded = true;
}
示例6: 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;
}
示例7: 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;
}
示例8: LoadLibraries
//General library functions
void LoadLibraries(void)
{
//Load Library eCompass
if(!eCompass.isLoaded())
{
eCompass.load();
}
if(!Altimeter.isLoaded())
{
Altimeter.load();
}
if(!Nordic.isLoaded())
{
Nordic.load();
}
if(!GPS.isLoaded())
{
GPS.load();
}
}
示例9: init
//----------------------------------------------------------------------------
void ctkPluginFrameworkContext::init()
{
log() << "initializing";
if (firstInit && ctkPluginConstants::FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT
== props[ctkPluginConstants::FRAMEWORK_STORAGE_CLEAN])
{
deleteFWDir();
firstInit = false;
}
// Pre-load libraries
// This may speed up installing new plug-ins if they have dependencies on
// one of these libraries. It prevents repeated loading and unloading of the
// pre-loaded libraries during caching of the plug-in meta-data.
if (props[ctkPluginConstants::FRAMEWORK_PRELOAD_LIBRARIES].isValid())
{
QStringList preloadLibs = props[ctkPluginConstants::FRAMEWORK_PRELOAD_LIBRARIES].toStringList();
QLibrary::LoadHints loadHints;
QVariant loadHintsVariant = props[ctkPluginConstants::FRAMEWORK_PLUGIN_LOAD_HINTS];
if (loadHintsVariant.isValid())
{
loadHints = loadHintsVariant.value<QLibrary::LoadHints>();
}
foreach(QString preloadLib, preloadLibs)
{
QLibrary lib;
QStringList nameAndVersion = preloadLib.split(":");
QString libraryName;
if (nameAndVersion.count() == 1)
{
libraryName = nameAndVersion.front();
lib.setFileName(nameAndVersion.front());
}
else if (nameAndVersion.count() == 2)
{
libraryName = nameAndVersion.front() + "." + nameAndVersion.back();
lib.setFileNameAndVersion(nameAndVersion.front(), nameAndVersion.back());
}
else
{
qWarning() << "Wrong syntax in" << preloadLib << ". Use <lib-name>[:version]. Skipping.";
continue;
}
lib.setLoadHints(loadHints);
log() << "Pre-loading library" << lib.fileName() << "with hints [" << static_cast<int>(loadHints) << "]";
if (!lib.load())
{
qWarning() << "Pre-loading library" << lib.fileName() << "failed:" << lib.errorString() << "\nCheck your library search paths.";
}
}
示例10: errorString
void tst_QLibrary::errorString()
{
QFETCH(int, operation);
QFETCH(QString, fileName);
QFETCH(bool, success);
QFETCH(QString, errorString);
QLibrary lib;
if (!(operation & DontSetFileName)) {
lib.setFileName(fileName);
}
bool ok = false;
switch (operation & OperationMask) {
case Load:
ok = lib.load();
break;
case Unload:
ok = lib.load(); //###
ok = lib.unload();
break;
case Resolve: {
ok = lib.load();
QCOMPARE(ok, true);
if (success) {
ok = lib.resolve("mylibversion");
} else {
ok = lib.resolve("nosuchsymbol");
}
break;}
default:
QFAIL(qPrintable(QString("Unknown operation: %1").arg(operation)));
break;
}
QRegExp re(errorString);
QString libErrorString = lib.errorString();
QVERIFY(!lib.isLoaded() || lib.unload());
QVERIFY2(re.exactMatch(libErrorString), qPrintable(libErrorString));
QCOMPARE(ok, success);
}
示例11: GetLibAPILevel
qint64 GetLibAPILevel (const QString& file)
{
if (file.isEmpty ())
return static_cast<quint64> (-1);
QLibrary library (file);
if (!library.load ())
return static_cast<quint64> (-1);
typedef quint64 (*APIVersion_t) ();
auto getter = reinterpret_cast<APIVersion_t> (library.resolve ("GetAPILevels"));
return getter ? getter () : static_cast<quint64> (-1);
}
示例12: QLibrary
QLibrary *QgsAuthMethodRegistry::authMethodLibrary( const QString &authMethodKey ) const
{
QLibrary *myLib = new QLibrary( library( authMethodKey ) );
QgsDebugMsg( "Library name is " + myLib->fileName() );
if ( myLib->load() )
return myLib;
QgsDebugMsg( "Cannot load library: " + myLib->errorString() );
delete myLib;
return 0;
}
示例13: QLibrary
QLibrary *QgsProviderRegistry::providerLibrary( QString const & providerKey ) const
{
QLibrary *myLib = new QLibrary( library( providerKey ) );
QgsDebugMsg( "Library name is " + myLib->fileName() );
if ( myLib->load() )
return myLib;
QgsDebugMsg( "Cannot load library: " + myLib->errorString() );
delete myLib;
return 0;
}
示例14: connect
PlazaClient::PlazaClient(QWidget *parent)
:QWidget(parent)
,ui(new Ui::wgtPlazaMainUI)
,m_process(NULL)
{
ui->setupUi(this);
connect(ui->btnStartGame,SIGNAL(clicked()),this,SLOT(sltStartGame()));
connect(ui->btnSendData,SIGNAL(clicked()),this,SLOT(sltSendData()));
connect(ui->btnCloseGame,SIGNAL(clicked()),this,SLOT(sltGameClosed()));
connect(qApp,SIGNAL(aboutToQuit()),this,SLOT());
QLibrary *libChannelModule = new QLibrary(this);
#if defined(Q_OS_WIN)
#if defined(QT_DEBUG)
libChannelModule->setFileName("H:/MyProjects/QtBasis/IPCTest/build-Debug/ChannelModule/debug/ChannelModule.dll");
#elif defined(QT_RELEASE)
libChannelModule->setFileName("H:/MyProjects/QtBasis/IPCTest/build-Release/ChannelModule/release/ChannelModule.dll");
#endif
#elif defined(Q_OS_LINUX)
#if defined(QT_DEBUG)
libChannelModule->setFileName("H:/MyProjects/QtBasis/IPCTest/build-Debug/ChannelModule/debug/ChannelModule.dll");
#elif defined(QT_RELEASE)
libChannelModule->setFileName("H:/MyProjects/QtBasis/IPCTest/build-Release/ChannelModule/release/ChannelModule.dll");
#endif
#endif
if(!libChannelModule->load())
{
qDebug() << "PlazaUI initial failed:ChannelModule load failed.ErrorString:" << libChannelModule->errorString() << endl;
}
else
{
pCreate f = (pCreate)libChannelModule->resolve("create");
if(f)
{
m_pChannelModule = f();
}
else
{
qDebug() << Utility::instance()->strErrorPosition(QString::fromUtf8(__FILE__), QString::fromUtf8(__FUNCTION__), __LINE__) << libChannelModule->errorString() << endl;
}
}
}
示例15: loadPlugin
bool PluginManager::loadPlugin(QString file, bool silent) {
QLibrary* library = new QLibrary(file);
if(!library->load()) {
if(!silent) {
QMessageBox::critical (_gi, tr("Error loading plugin"), library->errorString());
}
return false;
}
std::cout << file.toStdString() << " loaded" << std::endl;
QFunctionPointer ptr = library->resolve("loadPlugin");
if(ptr == 0) {
if(!silent) {
QMessageBox::critical (_gi, tr("Error loading plugin"), tr("Could not find the plugin's entry point \"loadPlugin\""));
}
return false;
}
std::cout << file.toStdString() << ": entry point found" << std::endl;
typedef Plugin* (*entryPoint)();
entryPoint getPlugin = reinterpret_cast<entryPoint>(ptr);
Plugin* plugin = getPlugin();
if(plugin==NULL) {
if(!silent) {
QMessageBox::critical (_gi, tr("Error loading plugin"), tr("The getPlugin entry point does not return a valid Plugin"));
}
return false;
}
std::cout << file.toStdString() << ": got Plugin" << std::endl;
vector<GenericOperation*> operations = plugin->getOperations();
std::cout << "Plugin " << plugin->getName() << " loaded : " << operations.size() << " operations "<< std::endl;
//PluginService* pluginService = new PluginService(plugin);
_plugins.insert(pair<string,Plugin*>(file.toStdString(), plugin));
_libraries.insert(pair<Plugin*,QLibrary*>(plugin, library));
//_gi->addService(pluginService);
emit addPlugin(plugin);
return true;
}