本文整理汇总了C++中QProcess::property方法的典型用法代码示例。如果您正苦于以下问题:C++ QProcess::property方法的具体用法?C++ QProcess::property怎么用?C++ QProcess::property使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QProcess
的用法示例。
在下文中一共展示了QProcess::property方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: chain
void QNetCtlTool::chain()
{
QProcess *proc = static_cast<QProcess*>(sender());
const QString tag = proc->property("QNetCtlTag").toString();
const QString info = proc->property("QNetCtlInfo").toString();
if (proc->exitStatus() != QProcess::NormalExit || proc->exitCode()) {
myClient->call(QDBus::NoBlock, "reply", tag, QString("ERROR: %1, %2").arg(proc->exitStatus()).arg(proc->exitCode()));
return;
}
myClient->call(QDBus::NoBlock, "reply", tag, QString::fromLocal8Bit(proc->readAllStandardOutput()));
QString cmd;
if (tag == "remove_profile") {
QFile::remove(gs_profilePath + info);
} else if (tag == "scan_wifi") {
myScanningDevices.removeAll(info);
myUplinkingDevices.removeAll(info);
cmd = TOOL(ip) + " link set " + info + " down";
}
if (cmd.isNull()) // should not happen
return;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.remove("LC_ALL");
env.remove("LANG");
proc = new QProcess(this);
proc->setProcessEnvironment(env);
// proc->setProperty("QNetCtlTag", tag);
// connect (proc, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(reply()));
connect (proc, SIGNAL(finished(int, QProcess::ExitStatus)), proc, SLOT(deleteLater()));
proc->start(cmd, QIODevice::ReadOnly);
}
示例2: reply
void QNetCtlTool::reply()
{
QProcess *proc = static_cast<QProcess*>(sender());
const QString tag = proc->property("QNetCtlTag").toString();
if (proc->exitStatus() != QProcess::NormalExit || proc->exitCode()) {
myClient->call(QDBus::NoBlock, "reply", tag, QString("ERROR: %1, %2").arg(proc->exitStatus()).arg(proc->exitCode()));
return;
}
myClient->call(QDBus::NoBlock, "reply", tag, QString::fromLocal8Bit(proc->readAllStandardOutput()));
}
示例3: slotDetailsProcess
void WPUserInfo::slotDetailsProcess(int i, QProcess::ExitStatus status)
{
QProcess *ipProcess = dynamic_cast<QProcess *>(sender());
QString ip;
if ( ! ipProcess )
return;
if ( i == 0 && status != QProcess::CrashExit ) {
QStringList output = QString::fromUtf8(ipProcess->readAll()).split('\n');
if ( output.size() == 2 && ! output.contains("failed") )
ip = output.at(1).split(' ').first();
if ( QHostAddress(ip).isNull() )
ip.clear();
}
QString host = ipProcess->property("host").toString();
delete ipProcess;
KConfigGroup group = KGlobal::config()->group("WinPopup");
QString theSMBClientPath = group.readEntry("SMBClientPath", "/usr/bin/smbclient");
if ( host == "LOCALHOST" ) //do not cycle
noComment = false;
detailsProcess = new QProcess(this);
QStringList args;
args << "-N" << "-g" << "-L" << host;
if ( ! ip.isEmpty() )
args << "-I" << ip;
connect(detailsProcess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotDetailsProcessFinished(int,QProcess::ExitStatus)));
detailsProcess->setProcessChannelMode(QProcess::MergedChannels);
detailsProcess->start(theSMBClientPath, args);
}
示例4: handlePackageUnarchFinished
void PackageProcessor::handlePackageUnarchFinished (int ret, QProcess::ExitStatus)
{
sender ()->deleteLater ();
QProcess *unarch = qobject_cast<QProcess*> (sender ());
int packageId = unarch->property ("PackageID").toInt ();
const auto& stagingDir = unarch->property ("StagingDirectory").toString ();
Mode mode = static_cast<Mode> (unarch->property ("Mode").toInt ());
auto cleanupGuard = std::shared_ptr<void> (nullptr,
[&stagingDir, this] (void*) { CleanupDir (stagingDir); });
if (ret)
{
QString errString = QString::fromUtf8 (unarch->readAllStandardError ());
qWarning () << Q_FUNC_INFO
<< "unpacker exited with"
<< ret
<< errString
<< "for"
<< packageId
<< unarch->property ("Path").toString ();
QString errorString = tr ("Unable to unpack package archive, unpacker exited with %1: %2.")
.arg (ret)
.arg (errString);
emit packageInstallError (packageId, errorString);
return;
}
int oldId = -1;
if (mode == MUpdate)
{
oldId = Core::Instance ().GetStorage ()->FindInstalledPackage (packageId);
if (!CleanupBeforeUpdate (oldId, packageId))
{
qWarning () << Q_FUNC_INFO
<< "unable to cleanup";
return;
}
}
QDir packageDir;
try
{
packageDir = Core::Instance ().GetPackageDir (packageId);
}
catch (const std::exception& e)
{
qWarning () << Q_FUNC_INFO
<< "while trying to get dir for package"
<< packageId
<< "got we exception"
<< e.what ();
QString errorString = tr ("Unable to get directory for the package: %1.")
.arg (QString::fromUtf8 (e.what ()));
emit packageInstallError (packageId, errorString);
return;
}
QDirIterator dirIt (stagingDir,
QDir::NoDotAndDotDot |
QDir::Readable |
QDir::NoSymLinks |
QDir::Dirs |
QDir::Files,
QDirIterator::Subdirectories);
while (dirIt.hasNext ())
{
dirIt.next ();
QFileInfo fi = dirIt.fileInfo ();
if (fi.isDir () ||
fi.isFile ())
if (!HandleEntry (packageId, fi, stagingDir, packageDir))
{
try
{
Remove (packageId);
}
catch (const std::exception& e)
{
qWarning () << Q_FUNC_INFO
<< "while removing partially installed package"
<< packageId
<< "got:"
<< e.what ();
}
QString errorString = tr ("Unable to copy "
"files from staging area to "
"destination directory.");
emit packageInstallError (packageId, errorString);
return;
}
}
switch (mode)
{
//.........这里部分代码省略.........