本文整理汇总了C++中QProcess::program方法的典型用法代码示例。如果您正苦于以下问题:C++ QProcess::program方法的具体用法?C++ QProcess::program怎么用?C++ QProcess::program使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QProcess
的用法示例。
在下文中一共展示了QProcess::program方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: kill
int myKill(pid_t pid, int signal)
{
if (pid == 0) {
return 0;
}
#ifdef Q_OS_WIN32
if (signal == 0) {
QProcess kill;
kill.start(
QStringLiteral("TASKLIST"),
QStringList() << QStringLiteral("/FI") << QString("PID eq %1").arg(pid) << QStringLiteral("/NH")
);
if (!kill.waitForStarted()) {
qWarning("QProcess can't start \"%s\"", kill.program().toStdString().c_str());
return -1;
}
if (!kill.waitForFinished()) {
qWarning("\"%s\" didn't write anything", kill.program().toStdString().c_str());
return -1;
}
return (kill.readAll().contains(QByteArray::number(pid)) ? 0 : -1);
}
QString cmd = QString("TASKKILL /F /PID %1").arg(pid);
errno = system(cmd.toStdString().c_str());
return (errno == 128 ? 0 : errno);
#else
return kill(pid, signal);
#endif
}
示例2: msgProcessError
static const QString msgProcessError(const QProcess &process, const QString &what)
{
QString result;
QTextStream(&result) << what << ": \"" << process.program() << ' '
<< process.arguments().join(QLatin1Char(' ')) << "\": " << process.errorString();
return result;
}
示例3: runApp
static Result runApp(const QString &execPath, const QStringList &args)
{
// QString outPipePath = FS::TmpFilePath("pipeOut");
QProcess app;
app.setProgram(execPath);
app.setArguments(args);
app.start();
if (!app.waitForStarted()) {
qWarning() << "Cmd Exec Failed:" << app.errorString();
return Result(Result::Failed, app.errorString(), "", app.program());
}
if (!app.waitForFinished(-1)) {
qWarning() << "waitForFinished Failed:" << app.errorString();
return Result(Result::Failed, app.errorString(), "", app.program());
}
auto standardError = app.readAllStandardError();
if (QProcess::NormalExit != app.exitStatus()) {
qWarning() << "exitStatus error:" << app.exitStatus() << standardError << app.program();
return Result(Result::Failed, standardError, "", app.program());
}
if (0 != app.exitCode()) {
qWarning() << "exitCode error:" << app.exitCode() << standardError << app.program();
return Result(Result::Failed, standardError, "", app.program());
}
Result rest(Result::Success, standardError, app.readAllStandardOutput());
return rest;
}
示例4: BakaSh
void BakaEngine::BakaSh(QStringList &args)
{
if(!args.empty())
{
QString arg = args.front();
args.pop_front();
QProcess *p = new QProcess(this);
p->start(arg, args);
connect(p, &QProcess::readyRead,
[=]
{
Print(p->readAll(), QString("%0(%1))").arg(p->program(), QString::number(quintptr(p))));
});
// connect(p, &QProcess::finished,
// [=](int, QProcess::ExitStatus)
// {
// delete p;
// });
}
else
RequiresParameters("mpv");
}
示例5: assemble
//.........这里部分代码省略.........
foreach (const QInstallerTools::PackageInfo &info, input.packages) {
QInstaller::ResourceCollection collection;
collection.setName(info.name.toUtf8());
qDebug() << "Creating resource archive for" << info.name;
foreach (const QString &file, info.copiedFiles) {
const QSharedPointer<Resource> resource(new Resource(file));
qDebug().nospace() << "Appending " << file << " (" << humanReadableSize(resource->size()) << ")";
collection.appendResource(resource);
}
input.manager.insertCollection(collection);
}
const QList<QInstaller::OperationBlob> operations;
BinaryContent::writeBinaryContent(&out, operations, input.manager,
BinaryContent::MagicInstallerMarker, BinaryContent::MagicCookie);
} catch (const Error &e) {
qCritical("Error occurred while assembling the installer: %s", qPrintable(e.message()));
QFile::remove(tempFile);
return EXIT_FAILURE;
}
if (!out.rename(targetName)) {
qCritical("Cannot write installer to %s: %s", targetName.toUtf8().constData(),
out.errorString().toUtf8().constData());
QFile::remove(tempFile);
return EXIT_FAILURE;
}
out.setAutoRemove(false);
#ifndef Q_OS_WIN
chmod755(out.fileName());
#endif
QFile::remove(tempFile);
#ifdef Q_OS_OSX
if (isBundle && !signingIdentity.isEmpty()) {
qDebug() << "Signing .app bundle...";
QProcess p;
p.start(QLatin1String("codesign"),
QStringList() << QLatin1String("--force")
<< QLatin1String("--deep")
<< QLatin1String("--sign") << signingIdentity
<< bundle);
if (!p.waitForFinished(-1)) {
qCritical("Failed to sign app bundle: error while running '%s %s': %s",
p.program().toUtf8().constData(),
p.arguments().join(QLatin1Char(' ')).toUtf8().constData(),
p.errorString().toUtf8().constData());
return EXIT_FAILURE;
}
if (p.exitStatus() == QProcess::NormalExit) {
if (p.exitCode() != 0) {
qCritical("Failed to sign app bundle: running codesign failed "
"with exit code %d: %s", p.exitCode(),
p.readAllStandardError().constData());
return EXIT_FAILURE;
}
}
qDebug() << "done.";
}
bundleBackup.release();
if (createDMG) {
qDebug() << "creating a DMG disk image...";
const QString volumeName = QFileInfo(input.outputPath).fileName();
const QString imagePath = QString::fromLatin1("%1/%2.dmg")
.arg(QFileInfo(bundle).path())
.arg(volumeName);
// no error handling as this is not fatal
QProcess p;
p.start(QLatin1String("/usr/bin/hdiutil"),
QStringList() << QLatin1String("create")
<< imagePath
<< QLatin1String("-srcfolder")
<< bundle
<< QLatin1String("-ov")
<< QLatin1String("-volname")
<< volumeName
<< QLatin1String("-fs")
<< QLatin1String("HFS+"));
qDebug() << "running " << p.program() << p.arguments();
p.waitForFinished(-1);
qDebug() << "removing" << bundle;
QDir(bundle).removeRecursively();
qDebug() << "done.";
}
#else
Q_UNUSED(signingIdentity)
#endif
return EXIT_SUCCESS;
}