本文整理汇总了C++中qputenv函数的典型用法代码示例。如果您正苦于以下问题:C++ qputenv函数的具体用法?C++ qputenv怎么用?C++ qputenv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qputenv函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gridUnitEnvironmentVariable
void gridUnitEnvironmentVariable() {
QByteArray gridUnit = QString::number(11).toLocal8Bit();
qputenv("GRID_UNIT_PX", gridUnit);
UCUnits units;
QCOMPARE(units.gridUnit(), 11.0);
qputenv("GRID_UNIT_PX", "");
}
示例2: dir
void IQmolApplication::initOpenBabel()
{
QDir dir(QApplication::applicationDirPath());
QString path;
#ifdef Q_OS_MAC
// Assumed directory structure: IQmol.app/Contents/MacOS/IQmol
dir.cdUp();
path = dir.absolutePath();
QApplication::addLibraryPath(path + "/Frameworks");
QApplication::addLibraryPath(path + "/PlugIns");
#endif
#ifdef Q_OS_WIN32
// Assumed directory structure: IQmol/bin/IQmol
dir.cdUp();
path = dir.absolutePath();
QApplication::addLibraryPath(path + "/lib");
QApplication::addLibraryPath(path + "/lib/plugins");
#endif
#ifdef Q_OS_LINUX
// Assumed directory structure: IQmol/IQmol
// This is so that when the executable is created it can be
// run from the main IQmol directory
path = dir.absolutePath();
QApplication::addLibraryPath(path + "/lib");
QApplication::addLibraryPath(path + "/lib/plugins");
#endif
// This is not used any more as we ship with a static
// version of OpenBabel
QString env(qgetenv("BABEL_LIBDIR"));
if (env.isEmpty()) {
env = path + "/lib/openbabel";
qputenv("BABEL_LIBDIR", env.toLatin1());
QLOG_INFO() << "Setting BABEL_LIBDIR = " << env;
}else {
QLOG_INFO() << "BABEL_LIBDIR already set: " << env;
}
env = qgetenv("BABEL_DATADIR");
if (env.isEmpty()) {
#if defined(Q_OS_LINUX)
// Overide the above for the deb package installation.
env ="/usr/share/iqmol/openbabel";
#else
env = path + "/share/openbabel";
#endif
qputenv("BABEL_DATADIR", env.toLatin1());
QLOG_INFO() << "Setting BABEL_DATADIR = " << env;
}else {
QLOG_INFO() << "BABEL_DATADIR already set: " << env;
}
}
示例3: dir
void IQmolApplication::initOpenBabel()
{
QDir dir(QApplication::applicationDirPath());
dir.cdUp();
QString path(dir.absolutePath());
#ifdef Q_WS_MAC
// Assumed directory structure: IQmol.app/Contents/MacOS/IQmol
QApplication::addLibraryPath(path + "/Frameworks");
QApplication::addLibraryPath(path + "/PlugIns");
#else
// Assumed directory structure: IQmol-xx/bin/IQmol
QApplication::addLibraryPath(path + "/lib");
QApplication::addLibraryPath(path + "/lib/plugins");
#endif
#ifdef Q_OS_LINUX
return;
#endif
QString env(qgetenv("BABEL_LIBDIR"));
if (env.isEmpty()) {
env = path + "/lib/openbabel";
qputenv("BABEL_LIBDIR", env.toAscii());
QLOG_INFO() << "Setting BABEL_LIBDIR = " << env;
}else {
QLOG_INFO() << "BABEL_LIBDIR already set: " << env;
}
env = qgetenv("BABEL_DATADIR");
if (env.isEmpty()) {
env = path + "/share/openbabel";
qputenv("BABEL_DATADIR", env.toAscii());
QLOG_INFO() << "Setting BABEL_DATADIR = " << env;
}else {
QLOG_INFO() << "BABEL_DATADIR already set: " << env;
}
#ifdef Q_WS_WIN
QLibrary openBabel("libopenbabel.dll");
#else
QLibrary openBabel("openbabel");
#endif
if (!openBabel.load()) {
QString msg("Could not load library ");
msg += openBabel.fileName();
QLOG_ERROR() << msg << " " << openBabel.errorString();
QLOG_ERROR() << "Library Paths:";
QLOG_ERROR() << libraryPaths();
msg += "\n\nPlease ensure the OpenBabel libraries have been installed correctly";
QMsgBox::critical(0, "IQmol", msg);
QApplication::quit();
return;
}
}
示例4: qputenv
void TestContactsd::envTest()
{
qputenv("CONTACTSD_PLUGINS_DIRS", "/usr/lib/contactsd-1.0/plugins/:/usr/lib/contactsd-1.0/plgins/");
mLoader->loadPlugins(QStringList());
QVERIFY2(mLoader->loadedPlugins().count() > 0, "failed to load plugins from evn variable");
qDebug() << mLoader->loadedPlugins();
qputenv("CONTACTSD_PLUGINS_DIRS", "");
mLoader->loadPlugins(QStringList());
}
示例5: QString
void ProxyManager::set()
{
QByteArray envvar = QString("http://%1:%2").arg(this->_host, QString::number(this->_port)).toUtf8();
qputenv("http_proxy", envvar);
qputenv("https_proxy", envvar);
qputenv("ftp_proxy", envvar);
qputenv("rsync_proxy", envvar);
}
示例6: path
void TestContactsd::importNonPlugin()
{
/* This is just a coverage test */
const QString path(QDir::currentPath() + "/data/");
qputenv("CONTACTSD_PLUGINS_DIRS", path.toAscii());
mLoader->loadPlugins(QStringList());
QStringList pluginList = mLoader->loadedPlugins();
QCOMPARE(pluginList.size(), 0);
qputenv("CONTACTSD_PLUGINS_DIRS", "");
}
示例7: qgetenv
void tst_QGetPutEnv::getSetCheck()
{
const char* varName = "should_not_exist";
QByteArray result = qgetenv(varName);
QCOMPARE(result, QByteArray());
QVERIFY(qputenv(varName, QByteArray("supervalue")));
result = qgetenv(varName);
QVERIFY(result == "supervalue");
qputenv(varName,QByteArray());
}
示例8: do_common_options_before_qapp
void do_common_options_before_qapp(const QOptions& options)
{
// it's too late if qApp is created. but why ANGLE is not?
if (options.value(QString::fromLatin1("egl")).toBool() || Config::instance().isEGL()) {
// only apply to current run. no config change
qputenv("QT_XCB_GL_INTEGRATION", "xcb_egl");
} else {
qputenv("QT_XCB_GL_INTEGRATION", "xcb_glx");
}
qDebug() << "QT_XCB_GL_INTEGRATION: " << qgetenv("QT_XCB_GL_INTEGRATION");
}
示例9: main
int main(int argc, char *argv[])
{
qputenv("GTK_IM_MODULE", QByteArray("qimsys"));
qputenv("QT_IM_MODULE", QByteArray("qimsys"));
QApplication app(argc, argv);
MainWindow mainWindow;
mainWindow.setOrientation(MainWindow::ScreenOrientationAuto);
mainWindow.showExpanded();
return app.exec();
}
示例10: main
int main(int argc, char *argv[])
{
/* Disable rwx memory.
This will also ensure full PAX/Grsecurity protections. */
qputenv("QV4_FORCE_INTERPRETER", "1");
qputenv("QT_ENABLE_REGEXP_JIT", "0");
QApplication a(argc, argv);
a.setApplicationVersion(QLatin1String("1.1.2"));
a.setOrganizationName(QStringLiteral("Ricochet"));
#if !defined(Q_OS_WIN) && !defined(Q_OS_MAC)
a.setWindowIcon(QIcon(QStringLiteral(":/icons/ricochet.svg")));
#endif
QScopedPointer<SettingsFile> settings(new SettingsFile);
SettingsObject::setDefaultFile(settings.data());
QString error;
QLockFile *lock = 0;
if (!initSettings(settings.data(), &lock, error)) {
QMessageBox::critical(0, qApp->translate("Main", "Ricochet Error"), error);
return 1;
}
QScopedPointer<QLockFile> lockFile(lock);
initTranslation();
/* Initialize OpenSSL's allocator */
CRYPTO_malloc_init();
/* Seed the OpenSSL RNG */
if (!SecureRNG::seed())
qFatal("Failed to initialize RNG");
qsrand(SecureRNG::randomInt(UINT_MAX));
/* Tor control manager */
Tor::TorManager *torManager = Tor::TorManager::instance();
torManager->setDataDirectory(QFileInfo(settings->filePath()).path() + QStringLiteral("/tor/"));
torControl = torManager->control();
torManager->start();
/* Identities */
identityManager = new IdentityManager;
QScopedPointer<IdentityManager> scopedIdentityManager(identityManager);
/* Window */
QScopedPointer<MainWindow> w(new MainWindow);
if (!w->showUI())
return 1;
return a.exec();
}
示例11: QStringLiteral
void SessionManager::setupEnvironment()
{
// Set paths only if we are installed onto a non standard location
QString path;
if (qEnvironmentVariableIsSet("PATH")) {
path = QStringLiteral("%1:%2").arg(INSTALL_BINDIR).arg(QString(qgetenv("PATH")));
qputenv("PATH", path.toUtf8());
}
if (qEnvironmentVariableIsSet("QT_PLUGIN_PATH")) {
path = QStringLiteral("%1:%2").arg(INSTALL_PLUGINDIR).arg(QString(qgetenv("QT_PLUGIN_PATH")));
qputenv("QT_PLUGIN_PATH", path.toUtf8());
}
if (qEnvironmentVariableIsSet("QML2_IMPORT_PATH")) {
path = QStringLiteral("%1:%2").arg(INSTALL_QMLDIR).arg(QString(qgetenv("QML2_IMPORT_PATH")));
qputenv("QML2_IMPORT_PATH", path.toUtf8());
}
if (qEnvironmentVariableIsSet("XDG_DATA_DIRS")) {
path = QStringLiteral("%1:%2").arg(INSTALL_DATADIR).arg(QString(qgetenv("XDG_DATA_DIRS")));
qputenv("XDG_DATA_DIRS", path.toUtf8());
}
if (qEnvironmentVariableIsSet("XDG_CONFIG_DIRS")) {
path = QStringLiteral("%1:%2:/etc/xdg").arg(INSTALL_CONFIGDIR).arg(QString(qgetenv("XDG_CONFIG_DIRS")));
qputenv("XDG_CONFIG_DIRS", path.toUtf8());
}
if (qEnvironmentVariableIsSet("XCURSOR_PATH")) {
path = QStringLiteral("%1:%2").arg(INSTALL_DATADIR "/icons").arg(QString(qgetenv("XCURSOR_PATH")));
qputenv("XCURSOR_PATH", path.toUtf8());
}
// Set XDG environment variables
if (qEnvironmentVariableIsEmpty("XDG_DATA_HOME")) {
QString path = QStringLiteral("%1/.local/share").arg(QString(qgetenv("HOME")));
qputenv("XDG_DATA_HOME", path.toUtf8());
}
if (qEnvironmentVariableIsEmpty("XDG_CONFIG_HOME")) {
QString path = QStringLiteral("%1/.config").arg(QString(qgetenv("HOME")));
qputenv("XDG_CONFIG_HOME", path.toUtf8());
}
// Set platform integration
qputenv("SAL_USE_VCLPLUGIN", QByteArray("kde"));
// qputenv("QT_PLATFORM_PLUGIN", QByteArray("Material"));
// qputenv("QT_QPA_PLATFORMTHEME", QByteArray("Material"));
// qputenv("QT_QUICK_CONTROLS_STYLE", QByteArray("Material"));
// qputenv("QT_WAYLAND_DISABLE_WINDOWDECORATION", QByteArray("1"));
// qputenv("XDG_CURRENT_DESKTOP", QByteArray("U2T"));
// qputenv("XCURSOR_THEME", QByteArray("Adwaita"));
// qputenv("XCURSOR_SIZE", QByteArray("16"));
}
示例12: qputenv
void CompositorLauncher::setupEnvironment()
{
// Make clients run on Wayland
if (m_hardware == BroadcomHardware) {
qputenv("QT_QPA_PLATFORM", QByteArray("wayland-brcm"));
qputenv("QT_WAYLAND_HARDWARE_INTEGRATION", QByteArray("brcm-egl"));
qputenv("QT_WAYLAND_CLIENT_BUFFER_INTEGRATION", QByteArray("brcm-egl"));
} else {
qputenv("QT_QPA_PLATFORM", QByteArray("wayland"));
}
qputenv("GDK_BACKEND", QByteArray("wayland"));
qunsetenv("WAYLAND_DISPLAY");
}
示例13: main
int main(int argc, char *argv[])
{
#if defined(Q_WS_X11)
QApplication::setGraphicsSystem("raster");
#elif defined (Q_WS_WIN)
qputenv("QML_ENABLE_TEXT_IMAGE_CACHE", "true");
#endif
#if defined(Q_WS_S60)
QApplication app(argc, argv);
#else
// Check for single running instance
QtSingleApplication app(argc, argv);
if (app.isRunning()) {
app.sendMessage("FOREGROUND");
return 0;
}
#endif
DuktoWindow viewer;
#ifndef Q_WS_S60
app.setActivationWindow(&viewer, true);
#endif
GuiBehind gb(&viewer);
viewer.showExpanded();
app.installEventFilter(&gb);
return app.exec();
}
示例14: initPython
void initPython()
{
//init python
qputenv("PYTHONIOENCODING", "utf-8");
Py_Initialize();
if (!Py_IsInitialized())
{
qDebug("Cannot initialize python.");
exit(-1);
}
//init module
geturl_obj = new GetUrl(qApp);
#if PY_MAJOR_VERSION >= 3
apiModule = PyModule_Create(&moonplayerModule);
PyObject *modules = PySys_GetObject("modules");
PyDict_SetItemString(modules, "moonplayer", apiModule);
#else
apiModule = Py_InitModule("moonplayer", methods);
#endif
PyModule_AddStringConstant(apiModule, "final_url", "");
Py_IncRef(exc_GetUrlError);
PyModule_AddObject(apiModule, "GetUrlError", exc_GetUrlError);
// plugins' dir
PyRun_SimpleString("import sys");
PyRun_SimpleString(QString("sys.path.insert(0, '%1/plugins')").arg(getAppPath()).toUtf8().constData());
PyRun_SimpleString(QString("sys.path.append('%1/plugins')").arg(getUserPath()).toUtf8().constData());
}
示例15: main
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
SignalHandler signalHandler;
Q_UNUSED(signalHandler)
if (QCoreApplication::arguments().length() < 2)
qFatal("Specify superuser user-id.");
bool ok;
auto headadminId = QCoreApplication::arguments()[1].toLongLong(&ok);
if (!ok)
qFatal("Specify superuser user-id.");
app.setApplicationName("Telegram-Bot");
app.setApplicationVersion(Bot::version());
//qputenv("QT_LOGGING_RULES", "tg.*=false");
qputenv("QT_LOGGING_RULES", "tg.*=false\nbot.*.debug=false");
//qputenv("DEBUG", "true");
Database database;
Bot bot(&database, headadminId);
bot.installModule(new Board);
bot.installModule(new Help);
bot.installModule(new Subscribe);
bot.installModule(new ConfigModule);
bot.installModule(new GroupModule);
bot.init();
return app.exec();
}