本文整理汇总了C++中QProcess::startDetached方法的典型用法代码示例。如果您正苦于以下问题:C++ QProcess::startDetached方法的具体用法?C++ QProcess::startDetached怎么用?C++ QProcess::startDetached使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QProcess
的用法示例。
在下文中一共展示了QProcess::startDetached方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doubleClickedOnEntry
void Pane::doubleClickedOnEntry(QModelIndex index)
{
Qt::KeyboardModifiers keybMod = QApplication::keyboardModifiers();
if(keybMod == Qt::ControlModifier || keybMod == Qt::ShiftModifier)
return;
QFileInfo fileInfo(mainWindow->fileSystemModel->filePath(index));
if(fileInfo.isDir())
moveTo(fileInfo.absoluteFilePath());
else if (fileInfo.isExecutable()) {
QProcess *process = new QProcess(this);
process->startDetached(fileInfo.absoluteFilePath());
}
else {
QProcess *process = new QProcess(this);
#ifdef __HAIKU__
process->startDetached("open \"" + fileInfo.absoluteFilePath() + "\"");
#endif
#ifdef Q_OS_WIN
process->startDetached("\"" + fileInfo.absoluteFilePath() + "\"");
// qDebug()<< "*\"" + fileInfo.absoluteFilePath() + "\"" ;
#endif
#ifdef __linux__
process->startDetached("open \"" + fileInfo.absoluteFilePath() + "\"");
// qDebug()<<"open \"" + fileInfo.absoluteFilePath() + "\"";
#endif
}
}
示例2: SummonBTCWallet
void BidPage::SummonBTCWallet()
{
QProcess *proc = new QProcess(this);
#ifdef linux
proc->startDetached("bitcoin-qt");
#elif _WIN32
proc->startDetached("bitcoin-qt.exe");
#endif
}
示例3: openTerminal
/*
* Opens a terminal based on your DE.
*/
void WMHelper::openTerminal(const QString& dirName){
QProcess *p = new QProcess(qApp->activeWindow());
QStringList s;
QFileInfo f(dirName);
if (f.exists()){
if(isXFCERunning() && UnixCommand::hasTheExecutable(ctn_XFCE_TERMINAL)){
s << "--working-directory=" + dirName;
p->startDetached( ctn_XFCE_TERMINAL, s );
}
else if (isKDERunning() && UnixCommand::hasTheExecutable(ctn_KDE_TERMINAL)){
s << "--workdir";
s << dirName;
if (UnixCommand::isRootRunning())
{
p->startDetached( "dbus-launch " + ctn_KDE_TERMINAL + " --workdir " + dirName);
}
else
{
p->startDetached( ctn_KDE_TERMINAL, s );
}
}
else if (isTDERunning() && UnixCommand::hasTheExecutable(ctn_TDE_TERMINAL)){
s << "--workdir";
s << dirName;
p->startDetached( ctn_TDE_TERMINAL, s );
}
else if (isLXDERunning() && UnixCommand::hasTheExecutable(ctn_LXDE_TERMINAL)){
s << "--working-directory=" + dirName;
p->startDetached( ctn_LXDE_TERMINAL, s );
}
else if (isMATERunning() && UnixCommand::hasTheExecutable(ctn_MATE_TERMINAL)){
s << "--working-directory=" + dirName;
p->startDetached( ctn_MATE_TERMINAL, s );
}
else if (isCinnamonRunning() && UnixCommand::hasTheExecutable(ctn_CINNAMON_TERMINAL)){
s << "--working-directory=" + dirName;
p->startDetached( ctn_CINNAMON_TERMINAL, s );
}
else if (UnixCommand::hasTheExecutable(ctn_XFCE_TERMINAL)){
s << "--working-directory=" + dirName;
p->startDetached( ctn_XFCE_TERMINAL, s );
}
else if (UnixCommand::hasTheExecutable(ctn_LXDE_TERMINAL)){
s << "--working-directory=" + dirName;
p->startDetached( ctn_LXDE_TERMINAL, s );
}
else if (UnixCommand::hasTheExecutable(ctn_XTERM)){
QString cmd = ctn_XTERM +
" -fn \"*-fixed-*-*-*-18-*\" -fg White -bg Black -title xterm -e \"" +
"cd " + dirName + " && /bin/bash\"";
p->startDetached( cmd );
}
}
}
示例4: editFile
/*
* Edits a file based on your DE.
*/
void WMHelper::editFile( const QString& fileName, EditOptions opt ){
QProcess *process = new QProcess(qApp->activeWindow());
QString p;
LinuxDistro distro = UnixCommand::getLinuxDistro();
if (distro == ectn_ARCHBANGLINUX && UnixCommand::hasTheExecutable(ctn_ARCHBANG_EDITOR))
{
p = ctn_ARCHBANG_EDITOR + " " + fileName;
}
else if (distro == ectn_MOOOSLINUX && UnixCommand::hasTheExecutable(ctn_MOOOS_EDITOR))
{
p = ctn_MOOOS_EDITOR + " " + fileName;
}
else if (isXFCERunning() && (UnixCommand::hasTheExecutable(ctn_XFCE_EDITOR) ||
UnixCommand::hasTheExecutable(ctn_XFCE_EDITOR_ALT))){
p = getXFCEEditor() + " " + fileName;
}
else if (isKDERunning() && UnixCommand::hasTheExecutable(ctn_KDE_EDITOR)){
p += ctn_KDE_EDITOR + " " + fileName;
}
else if (isKDERunning() && UnixCommand::hasTheExecutable(ctn_KDE4_EDITOR)){
p += ctn_KDE4_EDITOR + " " + fileName;
}
else if (isTDERunning() && UnixCommand::hasTheExecutable(ctn_TDE_EDITOR)){
p += ctn_TDE_EDITOR + " " + fileName;
}
else if (isMATERunning() && UnixCommand::hasTheExecutable(ctn_MATE_EDITOR)){
p = ctn_MATE_EDITOR + " " + fileName;
}
else if (isLXQTRunning() && UnixCommand::hasTheExecutable(ctn_LXQT_EDITOR)){
p = ctn_LXQT_EDITOR + " " + fileName;
}
if (UnixCommand::hasTheExecutable(ctn_ARCHBANG_EDITOR))
{
p = ctn_ARCHBANG_EDITOR + " " + fileName;
}
else if (UnixCommand::hasTheExecutable(ctn_CINNAMON_EDITOR)){
p = ctn_CINNAMON_EDITOR + " " + fileName;
}
else if (UnixCommand::hasTheExecutable(ctn_XFCE_EDITOR) || UnixCommand::hasTheExecutable(ctn_XFCE_EDITOR_ALT)){
p = getXFCEEditor() + " " + fileName;
}
if (UnixCommand::isRootRunning() || opt == ectn_EDIT_AS_NORMAL_USER)
{
process->startDetached("/bin/sh -c \"" + p + "\"");
}
else
{
process->startDetached(getSUCommand() + p);
}
}
示例5: run
void Interpreter::run()
{
QProcess* runner = new QProcess();
#if defined(Q_OS_WIN) //if current platform is Windows
runner->startDetached(path, arguments);
#elif defined(Q_OS_LINUX) //if current platform is Linux
runner->startDetached("xterm", QStringList()<< "-e" << path << arguments);
#endif
delete runner;
}
示例6: editFile
/*
* Edits a file based on your DE.
*/
void WMHelper::editFile( const QString& fileName ){
QProcess *process = new QProcess(qApp->activeWindow());
QStringList s;
if (!UnixCommand::isRootRunning()){
LinuxDistro distro = UnixCommand::getLinuxDistro();
if (distro == ectn_ARCHBANGLINUX && UnixCommand::hasTheExecutable(ctn_ARCHBANG_EDITOR))
{
QString p = ctn_ARCHBANG_EDITOR + " " + fileName;
process->startDetached(getSUCommand() + p);
}
else if (isXFCERunning() && (UnixCommand::hasTheExecutable(ctn_XFCE_EDITOR) ||
UnixCommand::hasTheExecutable(ctn_XFCE_EDITOR_ALT))){
QString p = getXFCEEditor() + " " + fileName;
process->startDetached(getSUCommand() + p);
}
else if (isKDERunning() && UnixCommand::hasTheExecutable(ctn_KDE_EDITOR)){
QString p = " -d -t --noignorebutton -c ";
p += ctn_KDE_EDITOR + " " + fileName;
process->startDetached(getSUCommand() + p);
}
else if (isKDERunning() && UnixCommand::hasTheExecutable(ctn_KDE4_EDITOR)){
QString p = " -d -t --noignorebutton -c ";
p += ctn_KDE4_EDITOR + " " + fileName;
process->startDetached(getSUCommand() + p);
}
else if (isTDERunning() && UnixCommand::hasTheExecutable(ctn_TDE_EDITOR)){
QString p = " -d -t --noignorebutton ";
p += ctn_TDE_EDITOR + " " + fileName;
process->startDetached(getSUCommand() + p);
}
else if (isMATERunning() && UnixCommand::hasTheExecutable(ctn_MATE_EDITOR)){
QString p = ctn_MATE_EDITOR + " " + fileName;
process->startDetached(getSUCommand() + p);
}
else if (isCinnamonRunning() && UnixCommand::hasTheExecutable(ctn_CINNAMON_EDITOR)){
QString p = ctn_CINNAMON_EDITOR + " " + fileName;
process->startDetached(getSUCommand() + p);
}
else if (UnixCommand::hasTheExecutable(ctn_XFCE_EDITOR) || UnixCommand::hasTheExecutable(ctn_XFCE_EDITOR_ALT)){
QString p = getXFCEEditor() + " " + fileName;
process->startDetached(getSUCommand() + p);
}
}
//Octopi was started by root account.
else{
if (UnixCommand::hasTheExecutable(ctn_XFCE_EDITOR) || UnixCommand::hasTheExecutable(ctn_XFCE_EDITOR_ALT))
s << getXFCEEditor() + " " + fileName;
else if (UnixCommand::hasTheExecutable(ctn_KDE_EDITOR))
s << ctn_KDE_EDITOR + " " + fileName;
else if (UnixCommand::hasTheExecutable(ctn_TDE_EDITOR))
s << ctn_TDE_EDITOR + " " + fileName;
process->startDetached("/bin/sh", s);
}
}
示例7: openFile
/*
* Opens a file based on your DE
*/
void WMHelper::openFile(const QString& fileName){
QString fileToOpen(fileName);
if (!UnixCommand::isTextFile(fileToOpen)){
int res = QMessageBox::question(qApp->activeWindow(), StrConstants::getConfirmation(),
StrConstants::getThisIsNotATextFile(),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No);
if ( res == QMessageBox::No ) return;
}
QProcess *p = new QProcess(qApp->activeWindow());
QStringList s;
LinuxDistro distro = UnixCommand::getLinuxDistro();
if (distro == ectn_ARCHBANGLINUX && UnixCommand::hasTheExecutable(ctn_ARCHBANG_FILE_MANAGER))
{
s << fileToOpen;
p->startDetached( ctn_ARCHBANG_FILE_MANAGER, s );
}
else if (isXFCERunning() && UnixCommand::hasTheExecutable(ctn_XFCE_FILE_MANAGER)){
s << fileToOpen;
p->startDetached( ctn_XFCE_FILE_MANAGER, s );
}
else if (isKDERunning() && UnixCommand::hasTheExecutable(ctn_KDE_FILE_MANAGER)){
s << "exec";
s << "file:" + fileToOpen;
p->startDetached( ctn_KDE_FILE_MANAGER, s );
}
else if (isKDERunning() && UnixCommand::hasTheExecutable(ctn_KDE4_FILE_MANAGER)){
s << fileToOpen;
p->startDetached( ctn_KDE4_OPEN, s );
}
else if (isTDERunning() && UnixCommand::hasTheExecutable(ctn_TDE_FILE_MANAGER)){
s << "exec";
s << "file:" + fileToOpen;
p->startDetached( ctn_TDE_FILE_MANAGER, s );
}
else if (isMATERunning() && UnixCommand::hasTheExecutable(ctn_MATE_EDITOR)){
s << fileToOpen;
p->startDetached( ctn_MATE_EDITOR, s );
}
else if (isCinnamonRunning() && UnixCommand::hasTheExecutable(ctn_CINNAMON_EDITOR)){
s << fileToOpen;
p->startDetached( ctn_CINNAMON_EDITOR, s );
}
else if (UnixCommand::hasTheExecutable(ctn_XFCE_FILE_MANAGER)){
s << fileToOpen;
p->startDetached( ctn_XFCE_FILE_MANAGER, s );
}
else if (UnixCommand::hasTheExecutable(ctn_LXDE_FILE_MANAGER)){
s << fileToOpen;
p->startDetached( ctn_LXDE_FILE_MANAGER, s );
}
}
示例8: dropEvent
void ITmagesApplet::dropEvent(QGraphicsSceneDragDropEvent *e)
{
// preventing next files drop
setAcceptDrops(false);
QString tempText = e->mimeData()->text();
QStringList paths = tempText.split("\n");
if (paths.count()>1) paths.removeLast();
// remove "file://", because we get 'file:///path_to_file'
paths.replaceInStrings(QRegExp("file://"),"");
// add supported files recursive
QStringList imagesPaths;
QFileInfo info;
for (int i = 0; i<paths.count(); ++i) {
info.setFile(paths.at(0));
if (info.isDir()) {
imagesPaths = loadImgFromFolder(info.absoluteFilePath());
} else if (info.isFile()) {
if (paths.at(i).contains(QRegExp("png$|jpg$|jpeg$|gif$", Qt::CaseInsensitive)))
imagesPaths.append(paths.at(i));
}
}
// start ITmages context menu extension
if (!imagesPaths.isEmpty()) {
QProcess load;
load.startDetached(path,imagesPaths);
}
setAcceptDrops(true);
}
示例9: createText
void MainWindow::createText() {
// Creates a new process to be called
QProcess *process = new QProcess;
#ifdef Q_WS_WIN
// Runs the CreateText.exe from debug folder
process->startDetached("CreateText");
// If the program runs, display a message saying it ran fine
if (process->waitForStarted() == true) {
qDebug() << "\nRunning CreateText";
}
#endif
#ifdef Q_WS_MACX
// Holds the path to the CreateText.exe
QString path = "open \"/Users/Teramino/Desktop/Qt/build-CreateText-Desktop_Qt_4_8_5-Debug/CreateText.app/Contents/MacOS/CreateText\"";
// Runs the CreateText.exe
process->start(path);
// If the program fails to start, display an error message and exit the program
if (process->waitForStarted() == false) {
qDebug() << "\nError starting CreateText";
qDebug() << process->errorString();
exit (-1);
}
// If the program runs, display a message saying it ran fine
if (process->waitForStarted() == true) {
qDebug() << "\nRunning CreateText";
}
#endif
}
示例10: askForRestart
void SelfUpdater::askForRestart()
{
QString text = "The Server Control Panel was updated from ";
text.append(QString("v%1 to v%2.").arg(APP_VERSION_SHORT, versionInfo["latest_version"].toString()));
QString infoText = "The update was installed. "
"You can restart the Server Control Panel now, "
"or continue working and restart later.";
QPixmap iconPixmap = QIcon(":/update").pixmap(80,80);
QMessageBox msgBox;
msgBox.setIconPixmap(iconPixmap);
msgBox.setWindowTitle("WPN-XM Server Control Panel - Self Updater");
msgBox.setText(text);
msgBox.setInformativeText(infoText);
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setButtonText(QMessageBox::Yes, tr("Restart SCP"));
msgBox.setButtonText(QMessageBox::No, tr("Continue"));
msgBox.setDefaultButton(QMessageBox::Yes);
if(msgBox.exec() == QMessageBox::Yes)
{
// Should we send a final farewell signal before we leave?
// QApplication::aboutToQuit(finalFarewellSignal);
// cross fingers and hope and pray, that starting the new process is slow
// and we are not running into the single application check.. ;)
QProcess p;
p.startDetached(QApplication::applicationFilePath());
QApplication::exit();
}
}
示例11: 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();
}
示例12: on_startSim_clicked
void MainWindow::on_startSim_clicked()
{
QProcess *sim = new QProcess(this);
sim->startDetached("C:\\UDK\\UDK-2013-07\\USARRunMaps\\ExampleMap.bat");
//QThread::sleep(3);
qDebug()<<sim->errorString();
}
示例13: launchInstaller
void Updater::launchInstaller()
{
if(!installer) {
QMessageBox mbox;
mbox.setText("Could not load the installer. Please download it manually and run the update.");
mbox.setIcon(QMessageBox::Warning);
mbox.exec();
return;
}
#if defined(Q_OS_WIN32)
QDesktopServices::openUrl(installer->fileName());
#elif defined(Q_OS_LINUX)
QDesktopServices::openUrl(installer->fileName());
#elif defined(Q_OS_DARWIN)
QProcess* installProc = new QProcess(this);
QString program = "open " + installer->fileName();
installProc->startDetached(program);
installProc->waitForStarted();
#endif
qApp->quit();
}
示例14: startDetached
bool FileEnvProcess::startDetached(const QString& program)
{
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);
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.setProcessChannelMode(QProcess::MergedChannels);
//QByteArray output = qprocess.readAll();
qprocess.execute("chmod", stringlst);
int rtn = qprocess.startDetached(*tmpFileNameStrPtr); //don't run this->execute; this would result in infinate recursion!!!
//cout << cct::bold("\nOutput: ") << output.data() << cct::bold("\nEnd of output") << endl;
return rtn;
}
示例15: startApplication
void SettingsUi::startApplication(QString appname)
{
QProcess proc;
proc.startDetached("/usr/bin/xdg-open" , QStringList() << appname);
QThread::msleep(100);
}