本文整理汇总了C++中QProcess::terminate方法的典型用法代码示例。如果您正苦于以下问题:C++ QProcess::terminate方法的具体用法?C++ QProcess::terminate怎么用?C++ QProcess::terminate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QProcess
的用法示例。
在下文中一共展示了QProcess::terminate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: voice
TTSStatus TTSFestival::voice(QString text, QString wavfile, QString* errStr)
{
qDebug() << "[Festival] Voicing " << text << "->" << wavfile;
QString path = RbSettings::subValue("festival-client",
RbSettings::TtsPath).toString();
QString cmd = QString("%1 --server localhost --otype riff --ttw --withlisp"
" --output \"%2\" --prolog \"%3\" - ").arg(path).arg(wavfile).arg(prologPath);
qDebug() << "[Festival] Client cmd: " << cmd;
QProcess clientProcess;
clientProcess.start(cmd);
clientProcess.write(QString("%1.\n").arg(text).toAscii());
clientProcess.waitForBytesWritten();
clientProcess.closeWriteChannel();
clientProcess.waitForReadyRead();
QString response = clientProcess.readAll();
response = response.trimmed();
if(!response.contains("Utterance"))
{
qDebug() << "[Festival] Could not voice string: " << response;
*errStr = tr("engine could not voice string");
return Warning;
/* do not stop the voicing process because of a single string
TODO: needs proper settings */
}
clientProcess.closeReadChannel(QProcess::StandardError);
clientProcess.closeReadChannel(QProcess::StandardOutput);
clientProcess.terminate();
clientProcess.kill();
return NoError;
}
示例2: sender
void
CheckDirModel::getFileInfoResult()
{
#ifdef Q_OS_MAC
QProcess* p = qobject_cast< QProcess* >( sender() );
Q_ASSERT( p );
QByteArray res = p->readAll().trimmed();
qDebug() << "Got output from GetFileInfo:" << res;
// 1 means /Volumes is hidden, so we show it while the dialog is visible
if ( res == "1" )
{
// Remove the hidden flag for the /Volumnes folder so all mount points are visible in the default (Q)FileSystemModel
QProcess* showProcess = new QProcess( this );
qDebug() << "Running SetFile:" << QString( "%1 -a v %2" ).arg( m_setFilePath ).arg( s_macVolumePath );
showProcess->start( QString( "%1 -a v %2" ).arg( m_setFilePath ).arg( s_macVolumePath ) );
connect( showProcess, SIGNAL( readyReadStandardError() ), this, SLOT( processErrorOutput() ) );
m_shownVolumes = true;
QTimer::singleShot( 500, this, SLOT( volumeShowFinished() ) );
}
p->terminate();
p->deleteLater();
#endif
}
示例3: mount
bool MountManager::mount()
{
if(!isPasswordCorrect()){
return false;
}
if(mountedDirExists()){
emit errorString(QString(QLatin1String("Already have something mounted in %1 ...continue")).arg(m_mountdir));
return true;
}
if(!QFileInfo(m_imgdir).exists()){
emit errorString(m_imgdir+QLatin1String("file does not exists\n"));
return false;
}
QProcess proc;
proc.setEnvironment(QProcess::systemEnvironment());
proc.start(QString(QLatin1String("sh -c \"echo %1 | sudo -S mount -o loop %2 %3\"")).arg(m_userPassWord).arg(m_imgdir).arg(m_mountdir));
if(!proc.waitForFinished()){
emit errorString(QString(QLatin1String("Can't mount image %1")).arg(QString(proc.errorString())));
return false;
}
if(!mountedDirExists()){
proc.waitForReadyRead();
emit errorString(QLatin1String(proc.readAllStandardError()));
return false;
}
proc.terminate();
messageString(QString(QLatin1String("Image mounted in %1")).arg(m_mountdir));
return true;
}
示例4: ProcessRun
inline QStringList ProcessRun(QString cmd, QStringList args){
//Assemble outputs
QStringList out; out << "1" << ""; //error code, string output
QProcess proc;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.insert("LANG", "C");
env.insert("LC_MESSAGES", "C");
proc.setProcessEnvironment(env);
proc.setProcessChannelMode(QProcess::MergedChannels);
if(args.isEmpty()){
proc.start(cmd, QIODevice::ReadOnly);
}else{
proc.start(cmd,args ,QIODevice::ReadOnly);
}
QString info;
while(!proc.waitForFinished(1000)){
if(proc.state() == QProcess::NotRunning){ break; } //somehow missed the finished signal
QString tmp = proc.readAllStandardOutput();
if(tmp.isEmpty()){ proc.terminate(); }
else{ info.append(tmp); }
}
out[0] = QString::number(proc.exitCode());
out[1] = info+QString(proc.readAllStandardOutput());
return out;
}
示例5: runProgram
PRL_RESULT CDspHaClusterHelper::runProgram(const QString & sPath, const QStringList & lstArgs, QProcess & proc)
{
WRITE_TRACE(DBG_INFO, "run %s %s", qPrintable(sPath), qPrintable(lstArgs.join(" ")));
proc.start(sPath, lstArgs);
if (!proc.waitForStarted(HAMAN_START_TMO)) {
WRITE_TRACE(DBG_FATAL, "Failed to run %s : %s",
QSTR2UTF8(sPath), QSTR2UTF8(proc.errorString()));
return PRL_ERR_CLUSTER_RESOURCE_ERROR;
}
if (!proc.waitForFinished(HAMAN_EXEC_TMO)) {
WRITE_TRACE(DBG_FATAL, "Failed to wait for finished %s : %s",
QSTR2UTF8(sPath), QSTR2UTF8(proc.errorString()));
proc.terminate();
return PRL_ERR_CLUSTER_RESOURCE_ERROR;
}
if (proc.exitCode()) {
WRITE_TRACE(DBG_FATAL, "%s failed : retcode : %d, stdout: [%s] stderr: [%s]",
QSTR2UTF8(sPath),
proc.exitCode(),
proc.readAllStandardOutput().constData(),
proc.readAllStandardError().constData()
);
return PRL_ERR_CLUSTER_RESOURCE_ERROR;
}
return PRL_ERR_SUCCESS;
}
示例6: flashZip
void RecoveryWidget::flashZip()
{
if (QMessageBox::question(this, tr("Flash Zip"), tr("Are you sure??"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
return;
this->romFileName = QFileDialog::getOpenFileName(this, tr("Open ROM File"), "/", tr("Zip files (*.zip)"));
QFileInfo fInfo = QFileInfo(this->romFileName);
FileList *fileList = new FileList;
fileList->name.append(this->romFileName);
fileList->size.append(QString::number(fInfo.size()));
fileList->date.append(fInfo.lastModified().toString());
fileList->type.append("file");
this->romFileName = fInfo.fileName();
QProcess tmp;
tmp.start("\"" + sdk + "\"adb shell su -c 'mount /sdcard'");
tmp.waitForFinished(-1);
tmp.terminate();
// if (this->dialog != NULL)
// delete this->dialog;
// this->dialog = new dialogKopiuj(this, fileList, this->sdk, dialogKopiuj::ComputerToPhone, fInfo.absolutePath(), "/sdcard/");
// this->dialog=new dialogKopiuj(this,fileList,this->sdk,"computerToPhone",this->phone,NULL,this->computer);
// if (this->alwaysCloseCopy)
// this->dialog->closeAfterFinished();
// if (this->dialogKopiujShowModal)
// this->dialog->setModal(true);
// this->dialog->show();
// connect(this->dialog,SIGNAL(finished(int)),this,SLOT(flashZipCopied()));
this->ui->stackedRecovery->setCurrentWidget(this->ui->pageFlashZIP);
}
示例7: getOSVersion
QString OSInfo::getOSVersion() {
#if defined(Q_WS_WIN)
OSVERSIONINFOEXW ovi;
memset(&ovi, 0, sizeof(ovi));
ovi.dwOSVersionInfoSize=sizeof(ovi);
GetVersionEx(reinterpret_cast<OSVERSIONINFOW *>(&ovi));
QString os;
os.sprintf("%d.%d.%d.%d", ovi.dwMajorVersion, ovi.dwMinorVersion, ovi.dwBuildNumber, (ovi.wProductType == VER_NT_WORKSTATION) ? 1 : 0);
return os;
#elif defined(Q_OS_MAC)
SInt32 major, minor, bugfix;
OSErr err = Gestalt(gestaltSystemVersionMajor, &major);
if (err == noErr)
err = Gestalt(gestaltSystemVersionMinor, &minor);
if (err == noErr)
err = Gestalt(gestaltSystemVersionBugFix, &bugfix);
if (err != noErr)
return QString::number(QSysInfo::MacintoshVersion, 16);
const NXArchInfo *local = NXGetLocalArchInfo();
const NXArchInfo *ai = local ? NXGetArchInfoFromCpuType(local->cputype, CPU_SUBTYPE_MULTIPLE) : NULL;
const char *arch = ai ? ai->name : "unknown";
QString os;
os.sprintf("%i.%i.%i (%s)", major, minor, bugfix, arch);
return os;
#else
#ifdef Q_OS_LINUX
QProcess qp;
QStringList args;
args << QLatin1String("-s");
args << QLatin1String("-d");
qp.start(QLatin1String("lsb_release"), args);
if (qp.waitForFinished(5000)) {
QString os = QString::fromUtf8(qp.readAll()).simplified();
if (os.startsWith(QLatin1Char('"')) && os.endsWith(QLatin1Char('"')))
os = os.mid(1, os.length() - 2).trimmed();
if (! os.isEmpty())
return os;
}
qWarning("OSInfo: Failed to execute lsb_release");
qp.terminate();
if (! qp.waitForFinished(1000))
qp.kill();
#endif
struct utsname un;
if (uname(&un) == 0) {
QString os;
os.sprintf("%s %s", un.sysname, un.release);
return os;
}
return QString();
#endif
}
示例8: connectWifi
void MainWindow::connectWifi()
{
QProcess *connect = new QProcess;
QSettings settings;
connect->setProcessChannelMode(QProcess::MergedChannels);
connect->start("\"" + settings.value("sdkPath").toString() + "\"adb connect " + this->ipAddress + ":" + this->portNumber);
connect->waitForFinished(2000);
connect->terminate();
delete connect;
}
示例9: stopProcess
bool SynchronousProcess::stopProcess(QProcess &p)
{
if (p.state() != QProcess::Running)
return true;
p.terminate();
if (p.waitForFinished(300))
return true;
p.kill();
return p.waitForFinished(300);
}
示例10: terminateGpgProcess
void ItemEncryptedLoader::terminateGpgProcess()
{
if (m_gpgProcess == nullptr)
return;
QProcess *p = m_gpgProcess;
m_gpgProcess = nullptr;
p->terminate();
p->waitForFinished();
p->deleteLater();
m_gpgProcessStatus = GpgNotRunning;
updateUi();
}
示例11: close
void ProcessSocket::close()
{
QProcess *proc = qobject_cast<QProcess *>(d);
Q_ASSERT(proc);
// Be nice to it, let it die peacefully before using an axe
// QTBUG-5990, don't call waitForFinished() on a process which hadn't started
if (proc->state() == QProcess::Running) {
proc->terminate();
proc->waitForFinished(200);
proc->kill();
}
}
示例12: QFAIL
void tst_q3buttongroup::clickLock()
{
// Task 177677
QProcess process;
process.start(QLatin1String("clickLock/clickLock"));
if (!process.waitForStarted(10000)) {
QFAIL("Could not launch process.");
}
if (!process.waitForFinished(15000)) {
process.terminate();
QFAIL("Could not handle click events properly");
}
}
示例13: enregistrer
void detailwnd::enregistrer( )
{
QString destFile = QFileDialog::getSaveFileName(this, tr("Sauver la video"),
"/home/dige7306/"+leAdresse->text(),
tr("Video (*.asf *.asx *.wsx *.wmv *.flv *.avi)"));
if ( destFile.isEmpty() ) return;
QStringList arg;
/* for eurosport
arg << "-cache";
arg << "4096";
arg << "-dumpstream";
arg << "-dumpfile";
arg << destFile;
arg << leAdresse->text();
QProcess::execute( "mplayer", arg );
arg.clear();
arg << "/usr/share/sounds/k3b_success1.wav";
QProcess::execute( "mplayer", arg );
*/
/* for atdhe.net */
arg << leAdresse->text();
QProcess::execute( "firefox", arg );
sleep( 5 ); /* wait for plugin to start */
QStringList f;
f << "Flash*";
QStringList files = QDir::temp().entryList( f );
qDebug() << files[0];
arg.clear();
arg << "-n" << "100000" << "--follow=name" << QDir::tempPath() + "/" + files[0];
QProcess *tail = new QProcess( this );
tail->setStandardOutputFile( destFile, QIODevice::Truncate );
tail->setStandardErrorFile( "/tmp/tail.err", QIODevice::Truncate );
tail->start( "tail", arg );
if ( tail->waitForStarted() )
{
int msec = teDuree->time().hour() * 60 * 60 + teDuree->time().minute() * 60;
msec *= 1000;
if ( msec == 0 ) msec = -1;
if ( !tail->waitForFinished(msec) )
{
tail->terminate();
}
qDebug() << " tail : " << tail->exitStatus() << " " << tail->exitCode() << endl;
}
else
{
qDebug() << " tail non demarre" << endl;
}
}
示例14: closeProcs
void US_Win::closeProcs( void )
{
QString names;
QList<procData*>::iterator p;
for ( p = procs.begin(); p != procs.end(); p++ )
{
procData* d = *p;
names += d->name + "\n";
}
QString isAre = ( procs.size() > 1 ) ? "es are" : " is";
QString itThem = ( procs.size() > 1 ) ? "them" : "it";
QMessageBox box;
box.setWindowTitle( tr( "Attention" ) );
box.setText( QString( tr( "The following process%1 still running:\n%2"
"Do you want to close %3?" )
.arg( isAre ).arg( names ).arg( itThem ) ) );
QString killText = tr( "&Kill" );
QString closeText = tr( "&Close Gracefully" );
QString leaveText = tr( "&Leave Running" );
QPushButton* kill = box.addButton( killText , QMessageBox::YesRole );
box.addButton( closeText, QMessageBox::YesRole );
QPushButton* leave = box.addButton( leaveText, QMessageBox::NoRole );
box.exec();
if ( box.clickedButton() == leave ) return;
for ( p = procs.begin(); p != procs.end(); p++ )
{
procData* d = *p;
QProcess* process = d->proc;
if ( box.clickedButton() == kill )
process->kill();
else
process->terminate();
}
// We need to sleep slightly (one millisecond) so that the system can clean
// up and properly release shared memory.
g.scheduleDelete();
US_Sleep::msleep( 1 );
}
示例15: changeDir
QString Repository::Git::GitUtils::makeTmpFileFromCommand( QString command, QString filepath )
{
bool ok = true;
// Ulozim si current working directory
QString cwd = QDir::currentPath();
// Nastavim absolutnu cestu k temp file ako template a zakazem automaticke mazanie
QTemporaryFile tempFile;
tempFile.setFileTemplate( QDir::toNativeSeparators( QDir::tempPath() + "/" + "qXXXXXX" ) );
tempFile.setAutoRemove( false );
// Ak sa nepodarilo vytvorit temp subor, tak nastavim flag "ok" na false a vypisem chybu
if ( !tempFile.open() ) {
qDebug() << "Nepodarilo sa vytvorit tmp subor";
ok = false;
}
// Ak sa podarilo vytvorit temp subor, tak zmenim current working directory
if ( ok ) {
ok = changeDir( filepath );
}
// Ak sa podarilo zmenit current working directory, tak skontroluje existenciu git repozitara
if ( ok ) {
ok = existGit( filepath );
}
// Ak existuje na danej ceste git repozitar, tak vykonam command a vystup ulozim do temp suboru
if ( ok ) {
QProcess process;
process.setStandardOutputFile( QDir::toNativeSeparators( tempFile.fileName() ) );
process.start( command );
process.waitForFinished();
process.close();
process.terminate();
}
// Vratim povodny current working directory, ak sa nepodari zmenit, vypisem do konzoly
if ( !changeDir( cwd ) ) {
qDebug() << "Nepodarilo sa vratit na povodny current working directory";
}
// Vratim absolutnu cestu k temp suboru
return tempFile.fileName();
}