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


C++ QLibrary::load方法代码示例

本文整理汇总了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"));
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:35,代码来源:qdnslookup_unix.cpp

示例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();
    }
开发者ID:3163504123,项目名称:phantomjs,代码行数:12,代码来源:GamepadsQt.cpp

示例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;
}
开发者ID:grimtraveller,项目名称:netbas,代码行数:25,代码来源:razorplugininfo.cpp

示例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;
}
开发者ID:cwarden,项目名称:quasar,代码行数:32,代码来源:firebird_driver.cpp

示例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;
}
开发者ID:multiple1902,项目名称:opencc-gui,代码行数:31,代码来源:converter.cpp

示例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;
}
开发者ID:kuiba,项目名称:dllapi,代码行数:26,代码来源:dllapi.cpp

示例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;
}
开发者ID:Nikoli,项目名称:qlandkartegt,代码行数:59,代码来源:CDeviceGarmin.cpp

示例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();
	}
}
开发者ID:bravesheng,项目名称:offroad-navi,代码行数:21,代码来源:ExternalLibrary.cpp

示例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.";
      }
    }
开发者ID:Eric89GXL,项目名称:CTK,代码行数:55,代码来源:ctkPluginFrameworkContext.cpp

示例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);
}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:40,代码来源:tst_qlibrary.cpp

示例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);
	}
开发者ID:SboichakovDmitriy,项目名称:leechcraft,代码行数:13,代码来源:ipluginloader.cpp

示例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;
}
开发者ID:landryb,项目名称:QGIS,代码行数:15,代码来源:qgsauthmethodregistry.cpp

示例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;
}
开发者ID:AnAvidDeveloper,项目名称:QGIS,代码行数:15,代码来源:qgsproviderregistry.cpp

示例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;
        }
    }
}
开发者ID:JandunCN,项目名称:AllInGithub,代码行数:46,代码来源:plazaclient.cpp

示例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;
}
开发者ID:eiimage,项目名称:eiimage,代码行数:44,代码来源:PluginManager.cpp


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