本文整理汇总了C++中QProcess::execute方法的典型用法代码示例。如果您正苦于以下问题:C++ QProcess::execute方法的具体用法?C++ QProcess::execute怎么用?C++ QProcess::execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QProcess
的用法示例。
在下文中一共展示了QProcess::execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
int FileEnvProcess::execute(const QString& program, const QStringList& arguments)
{
QByteArray programBa = program.toLatin1();
const char* programCharPtr = programBa.data();
QString* tmpFileNameStrPtr = new QString("/tmp/tmpRideFile.bash");
QFile* tmpRideFilePtr = new QFile(*tmpFileNameStrPtr);
tmpRideFilePtr->open(QIODevice::WriteOnly);
addHeader(tmpRideFilePtr);
tmpRideFilePtr->write(programCharPtr);
QByteArray tmpByteArray;
for(size_t i = 0; i < arguments.size(); i++)
{
tmpByteArray.append(arguments.at(i) + "\n");
tmpRideFilePtr->write(tmpByteArray);
tmpByteArray.clear();
}
tmpRideFilePtr->write("\nrm /tmp/tmpRideFile.bash");
tmpRideFilePtr->write("\necho \"Finished execution.\"");
tmpRideFilePtr->close();
QStringList stringlst; stringlst.push_back("+x"); stringlst.push_back("/tmp/tmpRideFile.bash");
QProcess qprocess;
qprocess.execute("chmod", stringlst);
return qprocess.execute(*tmpFileNameStrPtr); //don't run this->execute; this would result in infinate recursion!!!
}
示例2: ebubUnzip
bool classepub::ebubUnzip(QString fileName)
{
// QDir::homePath()+"/.kirtasse/download"
QDir dir;
QString pathToExtract=QDir::homePath()+"/.kirtasse/download/epub";
dir.mkdir(pathToExtract);
QProcess prosses;
if (dir.exists(pathToExtract)) //التاكد من وجود مجلد المؤقت
{
prosses.execute("rm -r "+pathToExtract);
prosses.waitForFinished();
}
//dir.mkdir(pathToExtract);
// prosses.execute("unzip \""+fileName+"\" -d "+pathToExtract);
if(QFile::exists("/usr/bin/7z")){
prosses.execute("7z x \""+fileName+"\" -o"+pathToExtract);
}else if(QFile::exists("/usr/bin/unzip")){
prosses.execute("unzip \""+fileName+"\" -d "+pathToExtract);
}else{
QMessageBox::information(0,"","please install 7z or unzip ");
}
prosses.waitForFinished();
ebubOpenContainer(QDir::homePath()+"/.kirtasse/download/epub");
curentPage=1;
return true;
}
示例3: copy
bool MTFile::copy(QString dest)
{
QFileInfo dest_fi(dest);
if (!dest_fi.dir().exists()) {
QDir().mkpath(dest_fi.dir().absolutePath());
}
#ifndef USE_UNIX_TOUCH_COMMAND
#ifndef Q_WS_MAC
return this->QFile::copy(dest);
#endif
#else
bool ok = false;
if (QFile::symLinkTarget(fileName()).isEmpty()) { ok = this->QFile::copy(dest); }
else {
QStringList arguments; QProcess cp;
arguments << "-R" << fileName() << dest;
ok = cp.execute("cp", arguments) == 0;
}
if (ok) {
QStringList arguments; QProcess touch;
arguments << "-cf" << "-r" << fileName() << dest;
if (touch.execute("touch", arguments) != 0) { return false; }
return QFileInfo(fileName()).lastModified() == dest_fi.lastModified();
} else { return false; }
return false;
#endif
}
示例4: defined
void
SpotifyAccount::killExistingResolvers()
{
QProcess p;
#if defined(Q_OS_UNIX)
const int ret = p.execute( "killall -9 spotify_tomahawkresolver" );
qDebug() << "Tried to killall -9 spotify_tomahawkresolver with return code:" << ret;
#elif defined(Q_OS_WIN)
const int ret = p.execute( "taskkill.exe /F /im spotify_tomahawkresolver.exe" );
qDebug() << "Tried to taskkill.exe /F /im spotify_tomahawkresolver.exe with return code:" << ret;
#endif
}
示例5: saveReport
void OOoReportBuilder::saveReport()
{
m_readyReportFile.clear();
QFile file(m_filename);
QFileInfo info(file);
QString newFile = m_outputDir + "\\" + info.baseName() + QString("_gen%1.%2")
.arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmss"))
.arg(info.completeSuffix());
if (!file.copy(newFile)) {
QMessageBox::critical(QApplication::activeWindow(),
"saveReport",tr("Can't copy file! "));
return;
}
m_readyReportFile = newFile;
QStringList args;
args << "a" << newFile
<< m_outputDir + "\\content.xml";
QProcess *arh = new QProcess();
arh->execute("7z", args);
QFile f(m_outputDir + "\\content.xml");
f.remove();
}
示例6: openAndTouch
bool MTFile::openAndTouch(QString other_path)
{
#ifdef Q_WS_WIN
//touch.setWorkingDirectory(QFileInfo(app->arguments().at(0)).absolutePath());
HANDLE in = CreateFileW(other_path.replace('/', '\\').toStdWString().c_str(),
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
FILETIME time;
GetFileTime(in, NULL, NULL, &time);
CloseHandle(in);
HANDLE out = CreateFileW(fileName().replace('/', '\\').toStdWString().c_str(),
GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
SetFileTime(out, NULL, NULL, &time);
CloseHandle(out);
return true;
#endif
if (!exists()) {
if (!open(QIODevice::ReadWrite)) return false;
}
QStringList arguments; QProcess touch;
arguments << "-cf" << "-r" << "\"" + other_path + "\"" << "\"" + fileName() + "\"";
if (touch.execute("touch", arguments) == 0) {
return true;
} else { return false; }
return false;
}
示例7: setInitialUiState
void MainWindow::setInitialUiState()
{
ui->mxfSoundRadio2->setChecked(1);
// set initial screen indexes
j2kSetStereoscopicState();
mxfSetStereoscopicState();
mxfSetHVState();
mxfSetSoundState();
mxfSetSlideState();
// Check For Kakadu
QProcess *kdu;
kdu = new QProcess(this);
int exitCode = kdu->execute("kdu_compress", QStringList() << "-version");
if (exitCode) {
int value = ui->encoderComboBox->findText("Kakadu");
ui->encoderComboBox->removeItem(value);
}
delete kdu;
// Set thread count
#ifdef Q_OS_WIN32
ui->threadsSpinBox->setMaximum(6);
#endif
ui->threadsSpinBox->setMaximum(QThreadPool::globalInstance()->maxThreadCount());
ui->threadsSpinBox->setValue(QThread::idealThreadCount());
ui->mxfSourceTypeComboBox->setCurrentIndex(0);
ui->mxfInputStack->setCurrentIndex(0);
ui->mxfTypeComboBox->setCurrentIndex(1);
ui->tabWidget->setCurrentIndex(0);
}
示例8: main
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QTextCodec* codec = QTextCodec::codecForName("CP1251");
QTextCodec::setCodecForLocale(codec);
if(argc == 6) {
QString prog_name = argv[5];
QString update_command = QString("%1 %2 %3%4 ").arg(argv[1]).arg(argv[2]).arg(argv[3]).arg(QDir::toNativeSeparators(argv[4]));
QProcess *vec = new QProcess;
qDebug() << "Update application...";
int res = vec->execute(update_command);
//TODO:
//Message Box with warning of fault update process if res != 0
// -2 = нет файла обновления
qDebug() << "Restart programm...";
vec->startDetached(prog_name);
delete vec;
return 0;
}
return a.exec();
}
示例9: GenTimeGrid
bool CalculateVelocityHandler::GenTimeGrid(float &p_wave, float &s_wave, int channel_id)
{
if (pickinfo_list_.count() == 0)
{
return false;
}
if (!GenTimeGridInfoFile(p_wave, s_wave, channel_id) || !GenObsFile(pickinfo_list_.at(0).event_id))
{
return false;
}
QStringList arguments;
arguments <<"TimegridInfo" <<"locPar" <<"obs";
QProcess proc;
int ret = proc.execute("./genTimeGrid", arguments);
if ((ret == -1)||(ret == -2))
{
return false;
}
return true;
}
示例10: startPhisService
bool PHIApplication::startPhisService()
{
qWarning() << "phiapp start" << _serverBin;
#ifdef PHIEMBEDEDSERVER
return false;
#else
if ( !QFile::exists( _serverBin ) ) return false;
qWarning() << "phiapp start" << _serverBin;
QProcess proc;
#ifdef Q_OS_WIN
proc.execute( _serverBin, QStringList() << L1( "-i" ) );
#endif
if ( proc.execute( _serverBin, QStringList() )!=0 ) return false;
return true;
#endif
}
示例11: getScopeAndLocals
bool Parse::getScopeAndLocals(Scope * sc, const QString &expr, const QString &ident)
{
// initialize scope if nothing better is found
sc->scope = "";
sc->localdef = "";
/* create a tags file for `expr' with function names only.
* The function with the highest line number is our valid scope
* --sort=no, because tags generation probably faster, and
* so I just have to look for the last entry to find 'my' tag
*/
QString command =
ctagsCmdPath +
" --language-force=c++ --sort=no --fields=fKmnsz --c++-kinds=fn -o \"" +
smallTagsFilePath + "\" \"" + parsedFilePath + '\"';
// I don't process any user input, so system() should be safe enough
QProcess ctags;
ctags.execute(command);
QFile::remove (parsedFilePath);
if (ctags.exitStatus() == QProcess::CrashExit)
return false;
/* find the last entry, this is our current scope */
tagFileInfo info;
tagFile *tfile = tagsOpen(smallTagsFilePath.toAscii(), &info);
tagEntry entry;
const char *scope = NULL;
if (tfile && info.status.opened)
{
if (tagsFirst(tfile, &entry) == TagSuccess)
{
do
scope = tagsField(&entry, "class");
while (tagsNext(tfile, &entry) == TagSuccess);
}
tagsClose(tfile);
}
/* must be before the 'type = extract_type_qualifier()' code, which modifies scope */
if (scope)
sc->scope = scope;
/* get local definition (if any) */
if (ident!="")
{
QString type = extractTypeQualifier(expr, ident);
if (type.length())
{
sc->localdef = type;
}
else
sc->localdef = "";
}
QFile::remove (smallTagsFilePath);
return true;
}
示例12: setInitialUiState
void MainWindow::setInitialUiState()
{
ui->mxfSoundRadio2->setChecked(1);
// set initial screen indexes
j2kSetStereoscopicState();
mxfSetStereoscopicState();
mxfSetInitialState();
// add encoders
ui->encoderComboBox->addItem("OpenJPEG", QVariant(OPENDCP_ENCODER_OPENJPEG));
#ifdef HAVE_RAGNAROK
ui->encoderComboBox->addItem("Ragnarok", QVariant(OPENDCP_ENCODER_RAGNAROK));
#endif
QProcess *kdu;
kdu = new QProcess(this);
int exitCode = kdu->execute("kdu_compress", QStringList() << "-version");
if (!exitCode) {
ui->encoderComboBox->addItem("Kakadu", QVariant(OPENDCP_ENCODER_KAKADU));
}
delete kdu;
// Set thread count
#ifdef Q_OS_WIN32
ui->threadsSpinBox->setMaximum(6);
#endif
ui->threadsSpinBox->setMaximum(QThreadPool::globalInstance()->maxThreadCount());
ui->threadsSpinBox->setValue(QThread::idealThreadCount());
ui->mxfSourceTypeComboBox->setCurrentIndex(0);
ui->mxfInputStack->setCurrentIndex(0);
ui->mxfTypeComboBox->setCurrentIndex(1);
ui->tabWidget->setCurrentIndex(0);
}
示例13: checkForUpdates
bool checkForUpdates(QString path) {
QProcess updater;
QStringList args = QStringList() << "-quickcheck" << "-justcheck";
int exit = updater.execute(path+"/wyUpdate", args);
return exit == 2;
}
示例14: runUpdateMimeDatabase
void MimeTypeWriter::runUpdateMimeDatabase()
{
const QString localPackageDir = KStandardDirs::locateLocal("xdgdata-mime", QString());
Q_ASSERT(!localPackageDir.isEmpty());
QProcess proc;
if (!proc.execute("update-mime-database", QStringList() << localPackageDir)) {
kWarning() << "update-mime-database exited with error code" << proc.exitCode();
}
}
示例15: executeCommand
/** Ejecuta la linea que le pasemos*/
int GsRenderEngine::executeCommand(const QString &d){
int rtn=-1;
QProcess convertgs;
if (testGsInstallation()){
m_command=QString("%1 %2").arg(m_strExecutable).arg(d);
rtn=convertgs.execute(m_command);
}
return rtn;
}