本文整理汇总了C++中QLibrary::setFileName方法的典型用法代码示例。如果您正苦于以下问题:C++ QLibrary::setFileName方法的具体用法?C++ QLibrary::setFileName怎么用?C++ QLibrary::setFileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLibrary
的用法示例。
在下文中一共展示了QLibrary::setFileName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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(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: 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;
}
示例4: 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;
}
}
}
示例5: 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.";
}
}
示例6: loadLibraries
void SupportLibraryLoader::loadLibraries() const{
std::map<quint32, QString> order;
QLibrary lib;
bool ok = order.size() > 0;
for(auto name : _order){
QFileInfo file;
if (QFileInfo(name.second).exists()) {
file = QFileInfo(name.second);
} else {
file = QFileInfo(_configLocation.absolutePath() + "/../" + name.second);
}
QString path = file.canonicalFilePath();
lib.setFileName(path);
ok = lib.load();
if ( !ok){
kernel()->issues()->log(TR("Could not load library ") + path + ",error :" + lib.errorString());
}
}
}
示例7: loadLibraries
void SupportLibraryLoader::loadLibraries() const{
std::map<quint32, QString> order;
QLibrary lib;
bool ok = order.size() > 0;
for(auto name : _order){
QFileInfo file;
if (QFileInfo(name.second).exists()) {
file = QFileInfo(name.second);
} else {
file = QFileInfo(_configLocation.absolutePath() + "/../" + name.second);
}
QString path = file.canonicalFilePath();
lib.setFileName(path);
ok = lib.load();
if ( !ok){
ERROR2(ERR_COULD_NOT_LOAD_2, TR("name"), "connector");
}
}
}
示例8: 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);
}
示例9: loadHints
void tst_QLibrary::loadHints()
{
QFETCH( QString, lib );
QFETCH( int, loadHints);
QFETCH( bool, result );
//QLibrary library( lib );
QLibrary library;
QLibrary::LoadHints lh(loadHints);
if (int(loadHints) != 0) {
lh |= library.loadHints();
library.setLoadHints(lh);
}
library.setFileName(lib);
QCOMPARE(library.loadHints(), lh);
bool ok = library.load();
if ( result ) {
QVERIFY( ok );
QVERIFY(library.unload());
} else {
QVERIFY( !ok );
}
}
示例10: Init
void Init( bool b, int rate2, int bits2, int chn2, int /*buff*/ )
{
mustReset = false;
if ( !b )
{
Save.odczytajopcje();
fs.Init();
fs.ApplyB();
}
PlErr = false;
if ( b )
{
if ( !isOpen )
{
if ( !pa_lib.isLoaded() )
{
QString libName = "libpulse-simple" + libExt;
#ifdef Q_WS_X11
libName += ".0";
#endif
pa_lib.setFileName( libName );
if ( !pa_lib.load() )
{
errStr = pa_lib.errorString();
PlErr = true;
return;
}
qmplay_pa_simple_new = ( _qmplay_pa_simple_new )pa_lib.resolve( "pa_simple_new" );
qmplay_pa_simple_free = ( _qmplay_pa_simple_free )pa_lib.resolve( "pa_simple_free" );
qmplay_pa_simple_write = ( _qmplay_pa_simple_write )pa_lib.resolve( "pa_simple_write" );
qmplay_pa_simple_read = ( _qmplay_pa_simple_read )pa_lib.resolve( "pa_simple_read" );
qmplay_pa_simple_flush = ( _qmplay_pa_simple_flush )pa_lib.resolve( "pa_simple_flush" );
if ( !qmplay_pa_simple_new || !qmplay_pa_simple_free || !qmplay_pa_simple_write || !qmplay_pa_simple_read || !qmplay_pa_simple_flush )
{
pa_lib.unload();
errStr = "błąd podczas pobierania funkcji z biblioteki: " + libName;
PlErr = true;
return;
}
}
switch ( bits2 )
{
case 8:
ss.format = PA_SAMPLE_U8;
break;
case 16:
ss.format = PA_SAMPLE_S16NE;
break;
case 24:
ss.format = PA_SAMPLE_S24NE;
break;
case 32:
ss.format = PA_SAMPLE_S32NE;
break;
}
ss.channels = chn2;
ss.rate = rate2;
attr.maxlength = ( uint32_t ) -1;
attr.tlength = delay * ( rate2 * ( bits2/8 ) * chn2 );
attr.prebuf = ( uint32_t ) -1;
attr.minreq = ( uint32_t ) -1;
attr.fragsize = attr.tlength;
pa_channel_map *chn_map = NULL;
if ( chn2 > 2 && chn2 <= 8 )
{
chn_map = new pa_channel_map;
chn_map->channels = chn2;
chn_map->map[ 0 ] = PA_CHANNEL_POSITION_FRONT_LEFT;
chn_map->map[ 1 ] = PA_CHANNEL_POSITION_FRONT_RIGHT;
chn_map->map[ 2 ] = PA_CHANNEL_POSITION_FRONT_CENTER;
chn_map->map[ 3 ] = PA_CHANNEL_POSITION_LFE;
chn_map->map[ 4 ] = PA_CHANNEL_POSITION_REAR_LEFT;
chn_map->map[ 5 ] = PA_CHANNEL_POSITION_REAR_RIGHT;
chn_map->map[ 6 ] = PA_CHANNEL_POSITION_SIDE_LEFT;
chn_map->map[ 7 ] = PA_CHANNEL_POSITION_SIDE_RIGHT;
}
pulse = qmplay_pa_simple_new( NULL, "QMPlay", PA_STREAM_PLAYBACK, NULL, "Output", &ss, chn_map, &attr, NULL );
delete chn_map;
if ( !pulse )
{
pa_lib.unload();
errStr = "błąd podczas otwierania wyjścia PulseAudio";
PlErr = true;
return;
}
if ( REC )
{
pulseREC = qmplay_pa_simple_new( NULL, "QMPlay", PA_STREAM_RECORD, NULL, "Input", &ss, chn_map, &attr, NULL );
if ( !pulseREC )
{
qmplay_pa_simple_free( pulse );
pa_lib.unload();
errStr = "błąd podczas otwierania wejścia PulseAudio";
PlErr = true;
return;
//.........这里部分代码省略.........
示例11: if
ModulePackage::ModulePackage(std::unique_ptr<QFile> file)
{
enum {
HEAD,
BRACE,
BODY
} state = HEAD;
enum {
OPERATOR,
FUNCTION,
TERMINAL
} type;
OperatorModule::StaticInfo opStatics;
FunctionModule::StaticInfo funcStatics;
OperatorInterface opInter;
FunctionInterface funcInter;
QList<QByteArray> head;
QString description;
QLibrary lib;
name_ = QFileInfo(*file).baseName();
if (file->open(QFile::ReadOnly)) {
while (!file->atEnd()) {
QByteArray line = file->readLine().trimmed();
if (! line.isEmpty()) {
switch (state) {
case HEAD:
head = line.split(':');
head[0] = head.at(0).trimmed();
head[1] = head.at(1).trimmed().toUpper();
if (head.at(1) == "OPERATOR") {
type = OPERATOR;
//opInter = new OperatorInterface;
} else if (head.at(1) == "FUNCTION") {
type = FUNCTION;
//funcInter = new FunctionInterface;
} else if (head.at(1) == "TERMINAL") {
type = TERMINAL;
}
state = BRACE;
break;
case BRACE:
if (line == "{") state = BODY;
break;
case BODY:
if (line == "}") {
switch (type) {
case OPERATOR:
modules.operators.append(OperatorModule(head.at(0), description, this, opInter, opStatics));
break;
case FUNCTION:
modules.functions.append(FunctionModule(head.at(0), description, this, funcInter, funcStatics));
break;
case TERMINAL:
modules.terminals.append(TerminalModule(head.at(0), description, this, (std::unique_ptr<CAS::AbstractArithmetic>(*)(const std::string &))lib.resolve(head[0] + "_jmodule")));
break;
}
state = HEAD;
} else {
auto colonPos = line.indexOf(':');
auto key = line.left(colonPos).trimmed();
auto value = line.right(line.length() - colonPos - 2).trimmed();
if (key == "description") {
description = value;
} else if (key == "matches") {
if (type == OPERATOR) {
opStatics.matches = std::make_shared<QString>(value);
} else if (type == FUNCTION) {
QList<QByteArray> matchParts = value.split(',');
funcStatics.matches = std::make_shared<QPair<QString, unsigned int>>(QString(matchParts.at(0)), matchParts.at(1).toUInt());
}
} else if (key == "priority") {
if (type == OPERATOR) opStatics.priority = value.toUInt();
else if (type == FUNCTION) funcStatics.priority = value.toUInt();
} else if (type == OPERATOR && key == "associativity") {
if (value == "left") opStatics.associativity = OperatorInterface::LEFT;
else if (value == "right") opStatics.associativity = OperatorInterface::RIGHT;
} else if (key == "lib") {
lib.setFileName(value);
std::string dbg = QString(head[0]).toStdString();
if (type == OPERATOR) opInter = ((OperatorInterface(*)())lib.resolve(head[0] + "_jmodule"))();
else if (type == FUNCTION) funcInter = ((FunctionInterface(*)())lib.resolve(head[0] + "_jmodule"))();
}
}
}
}
}
}
}
示例12: checkServerInstallationOK
//
// Returns 'true' if all seems OK.
//
bool FTNoIR_Protocol::checkServerInstallationOK()
{
if (!SCClientLib.isLoaded())
{
qDebug() << "SCCheckClientDLL says: Starting Function";
SCClientLib.setFileName("SimConnect.DLL");
ActivationContext ctx(142);
if (!SCClientLib.load()) {
qDebug() << "SC load" << SCClientLib.errorString();
return false;
}
} else {
qDebug() << "SimConnect already loaded";
}
//
// Get the functions from the DLL.
//
simconnect_open = (importSimConnect_Open) SCClientLib.resolve("SimConnect_Open");
if (simconnect_open == NULL) {
qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_Open function not found in DLL!";
return false;
}
simconnect_set6DOF = (importSimConnect_CameraSetRelative6DOF) SCClientLib.resolve("SimConnect_CameraSetRelative6DOF");
if (simconnect_set6DOF == NULL) {
qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_CameraSetRelative6DOF function not found in DLL!";
return false;
}
simconnect_close = (importSimConnect_Close) SCClientLib.resolve("SimConnect_Close");
if (simconnect_close == NULL) {
qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_Close function not found in DLL!";
return false;
}
//return true;
simconnect_calldispatch = (importSimConnect_CallDispatch) SCClientLib.resolve("SimConnect_CallDispatch");
if (simconnect_calldispatch == NULL) {
qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_CallDispatch function not found in DLL!";
return false;
}
simconnect_subscribetosystemevent = (importSimConnect_SubscribeToSystemEvent) SCClientLib.resolve("SimConnect_SubscribeToSystemEvent");
if (simconnect_subscribetosystemevent == NULL) {
qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_SubscribeToSystemEvent function not found in DLL!";
return false;
}
simconnect_mapclienteventtosimevent = (importSimConnect_MapClientEventToSimEvent) SCClientLib.resolve("SimConnect_MapClientEventToSimEvent");
if (simconnect_subscribetosystemevent == NULL) {
qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_MapClientEventToSimEvent function not found in DLL!";
return false;
}
simconnect_addclienteventtonotificationgroup = (importSimConnect_AddClientEventToNotificationGroup) SCClientLib.resolve("SimConnect_AddClientEventToNotificationGroup");
if (simconnect_subscribetosystemevent == NULL) {
qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_AddClientEventToNotificationGroup function not found in DLL!";
return false;
}
simconnect_setnotificationgrouppriority = (importSimConnect_SetNotificationGroupPriority) SCClientLib.resolve("SimConnect_SetNotificationGroupPriority");
if (simconnect_subscribetosystemevent == NULL) {
qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_SetNotificationGroupPriority function not found in DLL!";
return false;
}
qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect functions resolved in DLL!";
return true;
}