本文整理汇总了C++中QLibrary::errorString方法的典型用法代码示例。如果您正苦于以下问题:C++ QLibrary::errorString方法的具体用法?C++ QLibrary::errorString怎么用?C++ QLibrary::errorString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLibrary
的用法示例。
在下文中一共展示了QLibrary::errorString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例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: 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;
}
示例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: unload
bool unload(const char* dllname)
{
QLibrary *dll = library(dllname);
if (!dll) {
DBG("'%s' is not loaded\n", dllname);
return true;
}
if (!dll->unload()) {
DBG("%s", dll->errorString().toUtf8().constData());
return false;
}
sDllMap.erase(std::find_if(sDllMap.begin(), sDllMap.end(), std::bind2nd(map_value_equal<dllmap_t>(), dll))->first);
delete dll;
return true;
}
示例7: 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;
}
示例8: 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;
}
示例9: sipConvertFromNewType
static PyObject *meth_QLibrary_errorString(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QLibrary *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QLibrary, &sipCpp))
{
QString *sipRes;
Py_BEGIN_ALLOW_THREADS
sipRes = new QString(sipCpp->errorString());
Py_END_ALLOW_THREADS
return sipConvertFromNewType(sipRes,sipType_QString,NULL);
}
}
示例10: 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;
}
示例11: 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);
}
示例12: main
int main (int argc, char* argv[])
{
RazorDesktopApplication app(argc,argv);
XdgIcon::setThemeName(RazorSettings::globalSettings()->value("icon_theme").toString());
app.setWindowIcon(QIcon(QString(SHARE_DIR) + "/graphics/razor_logo.png"));
RazorSettings config("desktop");
app.setStyleSheet(razorTheme->qss("desktop"));
QString configId(config.value("desktop", "razor").toString());
QString libraryFileName = QString(DESKTOP_PLUGIN_DIR) + "libdesktop-" + configId + ".so";
qDebug() << "RazorDesktop: try to load " << libraryFileName;
QLibrary * lib = new QLibrary(libraryFileName);
PluginInitFunction initFunc = (PluginInitFunction) lib->resolve("init");
if (!initFunc)
{
qDebug() << lib->errorString();
delete lib;
return 0;
}
DesktopPlugin * plugin = initFunc(configId, &config);
Q_ASSERT(plugin);
if (plugin)
{
//lib->setParent(plugin);
qDebug() << " * Plugin loaded.";
qDebug() << plugin->info();
}
app.setDesktopPlugin(plugin);
return app.exec();
}
示例13: 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;
}
}
}
示例14: 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;
}
示例15: main
int main(int argc, char *argv[])
{
int ret = -1;
LibraryCleanupHandler cleanup;
{
::initApp("tokoloshtail", argc, argv);
QCoreApplication app(argc, argv);
if (!QDBusConnection::sessionBus().isConnected()) {
fprintf(stderr, "Cannot connect to the D-Bus session bus.\n"
"To start it, run:\n"
"\teval `dbus-launch --auto-syntax`\n");
return 1;
}
{
QDBusInterface iface(SERVICE_NAME, "/");
if (iface.isValid()) {
iface.call("quit");
}
}
// const QString pluginDirectory = Config::value<QString>("plugindir", PLUGINDIR); // ### Can't make this work
const QString pluginDirectory = Config::value<QString>("plugindir", QDir::cleanPath(QCoreApplication::applicationDirPath() + "/../plugins"));
Log::log(10) << "Using plugin directory" << pluginDirectory;
const QString backendName = Config::value<QString>("backend", "xine");
Log::log(10) << "Searching for backend" << backendName;
QDir dir(pluginDirectory);
if (!dir.exists()) {
Log::log(0) << pluginDirectory << " doesn't seem to exist";
return 1;
}
{
Tail tail;
Backend *backend = 0;
QLibrary *library = 0;
QHash<QLibrary*, BackendPlugin*> candidates;
foreach(const QFileInfo &fi, dir.entryInfoList(QDir::Files, QDir::Size)) {
QLibrary *lib = new QLibrary(fi.absoluteFilePath());
CreateBackend createBackend = 0;
if (lib->load() && (createBackend = (CreateBackend)lib->resolve("createTokoloshBackendInterface"))) {
BackendPlugin *interface = createBackend();
if (interface && interface->keys().contains(backendName, Qt::CaseInsensitive)) {
backend = interface->createBackend(&tail);
if (backend) {
library = lib;
break;
} else {
Log::log(0) << fi.absoluteFilePath() << "doesn't seem to be able to create a backend";
}
delete interface;
} else if (!interface) {
delete lib;
} else {
candidates[lib] = interface;
}
} else {
if (lib->isLoaded()) {
Log::log(1) << "Can't load" << fi.absoluteFilePath() << lib->errorString();
}
delete lib;
}
}
Q_ASSERT(!backend == !library);
if (!backend) {
for (QHash<QLibrary*, BackendPlugin*>::const_iterator it = candidates.begin(); it != candidates.end(); ++it) {
const bool hadBackend = backend != 0;
if (!backend)
backend = it.value()->createBackend(&app);
if (hadBackend || !backend) {
it.key()->unload();
delete it.key();
} else {
library = it.key();
}
delete it.value();
}
}
if (!backend) {
Log::log(0) << "Can't find a suitable backend";
return 1;
}
cleanup.library = library;
bool registered = false;
for (int i=0; i<5; ++i) {
if (QDBusConnection::sessionBus().registerService(SERVICE_NAME)) {
registered = true;
break;
}
::sleep(500);
}
if (!registered) {
Log::log(0) << "Can't seem to register service" << QDBusConnection::sessionBus().lastError().message();
return 1;
}
if (!tail.setBackend(backend)) {
Log::log(0) << backend->errorMessage() << backend->errorCode();
//.........这里部分代码省略.........