本文整理汇总了C++中QProcessEnvironment::keys方法的典型用法代码示例。如果您正苦于以下问题:C++ QProcessEnvironment::keys方法的具体用法?C++ QProcessEnvironment::keys怎么用?C++ QProcessEnvironment::keys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QProcessEnvironment
的用法示例。
在下文中一共展示了QProcessEnvironment::keys方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: keys
void tst_QProcessEnvironment::keys()
{
QProcessEnvironment e;
QVERIFY(e.isEmpty());
QVERIFY(e.keys().isEmpty());
e.insert("FOO", "bar");
QStringList result = e.keys();
QCOMPARE(result.length(), 1);
QCOMPARE(result.at(0), QString("FOO"));
e.clear();
e.insert("BAZ", "");
result = e.keys();
QCOMPARE(result.at(0), QString("BAZ"));
e.insert("FOO", "bar");
e.insert("A", "bc");
e.insert("HELLO", "World");
result = e.keys();
QCOMPARE(result.length(), 4);
// order is not specified, so use contains()
QVERIFY(result.contains("FOO"));
QVERIFY(result.contains("BAZ"));
QVERIFY(result.contains("A"));
QVERIFY(result.contains("HELLO"));
}
示例2: writeEnvironment
QT_END_NAMESPACE
static void writeEnvironment(Profile &p, const QProcessEnvironment &env)
{
foreach (const QString &name, env.keys())
p.setValue(QLatin1String("buildEnvironment.") + name, env.value(name));
}
示例3: addToEnvironment
void PokySDKKitInformation::addToEnvironment(const Kit *kit, Environment &env) const
{
FileName pokyEnvFile = environmentFile(kit);
if (pokyEnvFile.isEmpty())
return;
PokyRunner runner(pokyEnvFile.toString());
QProcessEnvironment pokyEnv = runner.processEnvironment();
foreach (QString key, pokyEnv.keys())
env.set(key, pokyEnv.value(key));
}
示例4: startTTY
// === PUBLIC ===
bool TTYProcess::startTTY(QString prog, QStringList args, QString workdir){
if(workdir=="~"){ workdir = QDir::homePath(); }
QDir::setCurrent(workdir);
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
setenv("TERM","vt100",1); //vt100: VT100 emulation support
unsetenv("TERMCAP");
/*setenv("TERMCAP","mvterm|vv100|mvterm emulator with ANSI colors:\
:pa#64:Co#8:AF=\E[3%dm:AB=\E[4%dm:op=\E[100m:tc=vt102:",1); //see /etc/termcap as well*/
QStringList filter = env.keys().filter("XTERM");
for(int i=0; i<filter.length(); i++){ unsetenv(filter[i].toLocal8Bit().data()); }
//if(env.contains("TERM")){ unsetenv("TERM"); }
//else if(env.contains
//Turn the program/arguments into C-compatible arrays
char cprog[prog.length()]; strcpy(cprog, prog.toLocal8Bit().data());
char *cargs[args.length()+2];
QByteArray nullarray;
for(int i=0; i<args.length()+2; i++){
// First arg needs to be the program
if ( i == 0 ) {
cargs[i] = new char[ prog.toLocal8Bit().size()+1];
strcpy( cargs[i], prog.toLocal8Bit().data() );
} else if(i<args.length()){
cargs[i] = new char[ args[i].toLocal8Bit().size()+1];
strcpy( cargs[i], args[i].toLocal8Bit().data() );
}else{
cargs[i] = NULL;
}
}
qDebug() << "PTY Start:" << prog;
//Launch the process attached to a new PTY
int FD = 0;
pid_t tmp = LaunchProcess(FD, cprog, cargs);
qDebug() << " - PID:" << tmp;
qDebug() << " - FD:" << FD;
if(tmp<0){ return false; } //error
else{
childProc = tmp;
//Load the file for close notifications
//TO-DO
//Watch the socket for activity
sn= new QSocketNotifier(FD, QSocketNotifier::Read);
sn->setEnabled(true);
connect(sn, SIGNAL(activated(int)), this, SLOT(checkStatus(int)) );
ttyfd = FD;
qDebug() << " - PTY:" << ptsname(FD);
return true;
}
}
示例5: main
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
// Try to get all of the env variables here
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
QStringList keys = environment.keys();
QList<QObject*> dataList;
foreach (QString key, keys) {
qDebug() << "key: " << key;
QString value = environment.value(key);
qDebug() << "value: " << value;
dataList.append(new DataObject(key, value));
}
示例6: insertEnv
void tst_QProcessEnvironment::insertEnv()
{
QProcessEnvironment e;
e.insert("FOO", "bar");
e.insert("A", "bc");
e.insert("Hello", "World");
QProcessEnvironment e2;
e2.insert("FOO2", "bar2");
e2.insert("A2", "bc2");
e2.insert("Hello", "Another World");
e.insert(e2);
QStringList keys = e.keys();
QCOMPARE(keys.length(), 5);
QCOMPARE(e.value("FOO"), QString("bar"));
QCOMPARE(e.value("A"), QString("bc"));
QCOMPARE(e.value("Hello"), QString("Another World"));
QCOMPARE(e.value("FOO2"), QString("bar2"));
QCOMPARE(e.value("A2"), QString("bc2"));
}
示例7: addChild
{
//qDebug() << "Dir:" << path << "does not exist. Skipping.";
continue;
}
name = QStandardPaths::displayName(i);
path.replace(" ", "\\ ");
cmd = "cd " + path;
addChild(new BookmarkCommandItem(name, cmd, this));
}
#endif
// system env - include dirs in the tree
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
foreach (QString i, env.keys())
{
path = env.value(i);
if (!d.exists(path) || !QFileInfo(path).isDir())
{
//qDebug() << "Env Dir:" << path << "does not exist. Skipping.";
continue;
}
path.replace(" ", "\\ ");
cmd = "cd " + path;
addChild(new BookmarkCommandItem(i, cmd, this));
}
}
};
class BookmarkFileGroupItem : public BookmarkGroupItem