qprocess

piping standard output into QLabel in Qt 4.7

懵懂的女人 提交于 2019-12-11 14:44:34
问题 I am trying to wrap a colleges c++ code in a Qt widget. However, his programs std output necessarily needs to be viewed. As of now I am assuming I will build a GUI and open a QProccess that will run his program (then send commands over that pipe). So my question is there anyway to read the standard output of that program and display it in a qlabel or something similar (i.e. what functions should I be looking into)? 回答1: As the process runs, the QProcess object will emit the

Qt5, symbolic link to a folder

Deadly 提交于 2019-12-11 13:30:23
问题 A dupe-ish question of this question, which (possibly) has got an outdated answer, as I can't get it to work in Qt5. I wish to create a symbolic link to a folder for a result similar to QFile::link() . Given that QDir doesn't have an equivalent function, QProcess (or an external library) seems like the way out if I'm up to snuff. How would this be managed in Qt5? Big thanks in advance. 回答1: There are shortcuts and hardlinks on Windows. I think mklink refers to hardlinks. It works for

QProcess does not complete creating file

自作多情 提交于 2019-12-11 05:39:54
问题 I am just trying to create a file with QProcess by the following source code: void Processmethod() { QDialog *ProcessMessage = new QDialog; Ui::DialogProcessMessage Dialog; Dialog.setupUi(ProcessMessage); ProcessMessage->setModal(true); ProcessMessage->setAttribute(Qt::WA_DeleteOnClose); ProcessMessage->show(); processmethodONE(); } void processmethodONE() { QString ProcessCommand = "w8 " + blablubli"; Prozess.setWorkingDirectory(Path); //QProcess "Prozess" is globaly defined Prozess

Attached child QProcess outliving parent

依然范特西╮ 提交于 2019-12-11 00:46:59
问题 I have a Qt application (Qt 5.5) that is launching from a usb drive on windows. In main I am using QProcess::start (NOT QProcess::startDetached) to start a new process. When killing the parent the child lives on and is functioning normally. The parent process is no longer listed in my taskManager, so it seems to be truly dead. Does anyone know why this might happen? 来源: https://stackoverflow.com/questions/36166866/attached-child-qprocess-outliving-parent

Qt - QProcess is not working

∥☆過路亽.° 提交于 2019-12-10 19:28:04
问题 I try to launch internet explorer, So I use the below code QProcess * process=new QProcess(this); QString temp="C:\\Program Files\\Internet\ Explorer\\iexplore.exe"; process->startDetached(temp.toStdString().c_str()); But it doesn't work. 回答1: Try: QProcess * process=new QProcess(this); QString temp="\"C:\\Program Files\\Internet Explorer\\iexplore.exe\""; process->startDetached(temp); You need to use escaped quotes since the path has a space in it, or possibly escape all the spaces (you

How to run a detached application by terminal command in Qt application?

旧巷老猫 提交于 2019-12-10 19:08:30
问题 I want to use commands: cd /opencv/opencv-3.0.0-alpha/samples/cpp/ ./cpp-example-facedetect lena.jpg to run a sample code of OpenCV on clicked() method of button in Qt application. So I use: void MainWindow::on_btSample_clicked() { QProcess process1; QProcess process2; process1.setStandardOutputProcess(&process2); process1.start("cd /opencv/opencv-3.0.0-alpha/samples/cpp"); process1.waitForBytesWritten(); process2.start("./cpp-example-facedetect lena.jpg"); } I added necessary library to use

Qt avoid warning 'QProcess: destroyed while process still running

与世无争的帅哥 提交于 2019-12-10 15:44:34
问题 Simplest code: void test { QProcess p; p.start("sleep 10"); p.waitForBytesWritten(); p.waitForFinished(1); } Of course, the process can't be finished before the end of the function, so it displays a warning message: QProcess: Destroyed while process ("sleep") is still running. I want this message not to be shown - I should destroy the process by myself before end of function, but I can't find how to do this correctly: p.~QProcess(), p.terminate(), p.kill() can't help me. NOTE: I don't want

Piping output of a QIODevice to a QTextEdit

社会主义新天地 提交于 2019-12-10 11:57:58
问题 How to I make the output of a QIODevice ( QProcess , specifically) go into a QTextEdit in real time? 回答1: Connect the QProcess::readyRead signal to a slot that then reads from the QProcess using QProcess::readAllStandardOutput and writes the text to the QTextEdit with QTextEdit::append. 回答2: Write own class! Header: class MyProcess : public QProcess { Q_OBJECT ... protected: virtual qint64 readData( char * data, qint64 maxlen ); ... }; Source: qint64 MyProcess::readData( char * data, qint64

Run another executable in my Qt app

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-08 08:42:51
问题 I wrote two Qt applications. One is the main and the other is a side way. I am running Linux. I read about QProcess so I wrote this code: QApplication a(argc, argv); MainWindow w; w.show(); QProcess P(&w); QString programPath; programPath= "/Documents/Qt/test1-build-desktop-Qt_4_8_1_in_PATH__System__Release/test1"; P.start(programPath); return a.exec(); However, nothing happens and just my main app ( w ) runs. What is my fault? Please help me. 回答1: the issue is that P.start(programPath); is a

Is QProcess::finished emitted if the child process crashes?

半腔热情 提交于 2019-12-08 08:03:51
问题 The documentation says that the error() signal will be emitted if the child process crashes, but would finished() be emitted as well or is it only emitted when it exits successfully? 回答1: Yes. And it returns you status, as docs state: void QProcess::finished ( int exitCode, QProcess::ExitStatus exitStatus ) [signal] QProcess::NormalExit 0 The process exited normally. QProcess::CrashExit 1 The process crashed. 回答2: You can find out by testing it. Write a small program that does a NULL pointer