Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    1. Home
    2. Tags
    3. qprocess
    Log in to post

    • SOLVED QML start external program: use QProcess fail build
      QML and Qt Quick • qml qprocess build failed • • warcomeb  

      4
      0
      Votes
      4
      Posts
      42
      Views

      @J-Hilk Thanks for your help! It works!
    • UNSOLVED QProcess does not recognize input path with accent
      General and Desktop • c++ qprocess windows10 • • xchess64  

      8
      0
      Votes
      8
      Posts
      27
      Views

      @JonB: yes, and then use QString::fromUtf8()
    • UNSOLVED Using QTquick 1 to trigger a bash script on button click
      QML and Qt Quick • qprocess qt4 process qtquick1.1 • • jcthomas556  

      5
      0
      Votes
      5
      Posts
      49
      Views

      @JonB This is a quote from the example given on the link listed. It's from QT, in an explanation of how this works. It's not a string that I came up with, or that I'm using.
    • UNSOLVED Can't kill QProcess in overriden closeEvent()
      General and Desktop • qprocess qcloseevent • • nikko1991  

      12
      0
      Votes
      12
      Posts
      98
      Views

      @nikko1991 said in Can't kill QProcess in overriden closeEvent(): I believe shutting down ROS from Qt/other program is slower than from terminal I don't claim to understand what you are saying in your post, and I probably won't understand even if you try to explain more! But I do not know what you could mean by this sentence. The "terminal" (i.e. a "shell") simply is "from other program". There is no difference between a shell and any other program under Linux, and if you can do something from a shell you can do it from a program you write. As a separate matter, I wouldn't use the blocking QProcess::waitFor...() methods anyway, at least not in the case of issues with the program spawned. There is no need to, as there are the asynchronous signals from QProcess available to you, which is how the waitFor()s are implemented anyway. So if you are saying these are causing you problems, don't use them.
    • SOLVED Qprocess reading execution output Simentensously
      General and Desktop • qprocess qtcore command line shell • • Amirhos  

      9
      0
      Votes
      9
      Posts
      80
      Views

      @Amirhos Unfortunately this is difficult, especially under Windows. If, for whatever reason, the third-party app is buffering its output at its own side then you cannot force it down the pipe to your parent, it depends how the code is written at their side....
    • UNSOLVED Sending curl command to command prompt using QProcess
      General and Desktop • c++ qprocess api curl • • Ahsan Niaz  

      20
      0
      Votes
      20
      Posts
      141
      Views

      I am really thankful to everyone who replied to me and corrected my mistakes. Your help will help me finish my work quicker. Thanks @Christian-Ehrlicher , @Bonnie @JonB
    • SOLVED Qprocess runs correctly in debug but in release mode it doesn't run correctly
      General and Desktop • qprocess linux chromeos waitforfinished • • TahmDev  

      11
      0
      Votes
      11
      Posts
      90
      Views

      @SGaist as a matter of fact it did... Then I used Qthread::msleep(500); I will try using it asynchronously today and get back to you with the result...
    • UNSOLVED Detaching from process
      General and Desktop • qprocess • • Massimiliano75  

      11
      0
      Votes
      11
      Posts
      108
      Views

      @JonB sorry if i reply now, but my company has closed for a week, launching a script was an example, any qprocess gives me that message also if i start ls, arp-scan or others. if i start a program locally i don't have this problem, the problem occurs if i start a program in remote debug, but the versions (local and remote) of gdb and linux are the same
    • SOLVED Opening command shell when starting a Qprocess
      General and Desktop • c++ qprocess exe command line • • JCSB  

      5
      0
      Votes
      5
      Posts
      48
      Views

      @SGaist Thank you, this has solved my issue!! :D
    • UNSOLVED Using QProcess to Create Mock Command Prompt
      General and Desktop • qprocess command line command • • cstevenson  

      8
      0
      Votes
      8
      Posts
      100
      Views

      @cstevenson Please also connect a slot to https://doc.qt.io/qt-5/qprocess.html#errorOccurred The process is probably not running when you call write().
    • SOLVED QProcess waitForFinish exits immediately
      General and Desktop • python qprocess script output • • Kyeiv  

      7
      0
      Votes
      7
      Posts
      134
      Views

      @Kyeiv OK, but please put the error checking code in anyway. With OS commands you never know what might go wrong (just like you discovered), so it's important to check for & report all errors! And especially if you are going to be distributing this....
    • UNSOLVED QProcess with powershell command still running
      General and Desktop • qprocess powershell • • TomNow99  

      11
      0
      Votes
      11
      Posts
      219
      Views

      The problem might be that you have two nested calls to PowerShell without exiting them. A quick search shows people reporting the inner PowerShell call (with -Verb runas) keeps the console window open. So, instead of the netsh command you might want to provide a script that has the netsh command and an exit. Or maybe you can concatenate the two directly in the -ArgumentList (I don't have much experience with PowerShell, but in Linux I could separate commands with a semicolon).
    • SOLVED Access to Windows network shared folder from linux
      General and Desktop • linux qprocess mount network shared • • Francis Chapet  

      8
      0
      Votes
      8
      Posts
      245
      Views

      @mrjj ...Which is one of the 1,000 reasons I would not be accepting this Qt application if it says I need to run it sudo... :)
    • SOLVED crash at GetExitCodeProcess in qprocess_win.cpp
      General and Desktop • qprocess windows 10 • • thamht4190  

      5
      0
      Votes
      5
      Posts
      172
      Views

      Thanks @JonB . The problem seems gone when I remove these "process terminate" code.
    • UNSOLVED Problem recording webcam with FFMPEG and QProcess
      General and Desktop • qprocess fmpeg webca • • Guigiidre  

      9
      0
      Votes
      9
      Posts
      487
      Views

      @jsulm I did :-) but I have no more information... Anyway I will stop using the QProcess class to reccord video with my webcam, it seems too tricky, instead I think I will use a library like LibVLC to do it...
    • SOLVED why QProcess is not working in MAC os?
      General and Desktop • qprocess bundle macros qt 5.11.0 • • Yash001  

      19
      0
      Votes
      19
      Posts
      1594
      Views

      @JonB Thank you for correct direction. I will modify my code and use it finished Signal for updating dialog box.
    • SOLVED QProcess not reading stdout
      General and Desktop • c++ qprocess stdout • • CaffeinatedGecko  

      5
      0
      Votes
      5
      Posts
      1160
      Views

      @JonB Thanks! That saved me a good deal of troubleshooting. It turned out the problem was a hard path to a file inside the C program which caused it to run correctly when invoked from it's native directory, but caused a segfault when called by Qt since the paths were different. The problem is completely fixed now.
    • SOLVED The true meaning of the warning for QProcess::waitForFinished
      General and Desktop • gui qprocess freeze waitforfinished document • • Shinichiro  

      10
      0
      Votes
      10
      Posts
      1202
      Views

      Hi, Thank you for your reply. I totally changed my implementation using the signal and slots. Thank you so much again.
    • SOLVED QProcess for a Sudo, dd Command and a Pipe for md5sum
      General and Desktop • qprocess sudo pipe • • BitFlipper  

      8
      0
      Votes
      8
      Posts
      1412
      Views

      @BitFlipper b) I tried that already with no luck Then you did not try right! There is an example of just what you need at the link I posted. The outline of this approach would be: QProcess ddProcess, md5sumProcess; ddProcess.setStandardOutputProcess(&md5sumProcess); ddProcess.start("sudo dd if=/dev/sda2 of=/dev/sdb2 bs=4096 conv=noerror"); md5sumProcess.start("md5sum"); md5sumProcess.waitForFinished(); However, it's probably more suitable for you to issue the whole lot as a single string passed to /bin/sh or /bin/bash with the -c argument, and let it figure the | for you., as per my example earlier. So my command changes in this function, should I build a custom string every time and pass it in as one statement? Yes. I always practice in terminal first For this purpose make yourself use /bin/sh -c "sudo dd ... | md5sum" as that is what you will need. Be careful if anything in your command requires its own quoting (your current example does not), as the whole command itself is now inside quotes. As I wrote earlier, your md5sum is not going to see the contents from the dd. Your example does not lend itself to checksumming as it uses a single dd if=... of=... which does the input & output in one go. What you want is for the output from the dd to go both to the output file and to md5sum. Here are two possibilities for you to play with: sudo dd if=/dev/sda2 bs=4096 conv=noerror | sudo tee /dev/sdb2 | md5sum sudo dd if=/dev/sda2 bs=4096 conv=noerror | tee >(md5sum 1>&2) | sudo dd of=/dev/sdb2 bs=4096 In the first case we tee the output off to /dev/sdb2 as well as letting it through to md5sum. Simpl-ish, but you lose the ability to specify the bs= for the output to /dev/sdb2. I don't know if that matters to you. In the second case you use "shell magic" (you'll probably have to use /bin/bash not /bin/sh, I think) to send tee's output to md5sum process as well as passing it onto a second dd to do the output. I have made it so md5sum's output goes to standard error instead of standard output. Finally: is all this dd and checksum stuff worth it? Probably not. Have a read of, say, https://unix.stackexchange.com/a/45854/104736 for alternative suggestions.
    • UNSOLVED Calling kextunload / kextload on mac (need sudo privilege)
      General and Desktop • qprocess sudo administrator privileges kext • • AloyseTech  

      3
      0
      Votes
      3
      Posts
      445
      Views

      Hi, I have found something that works but that is not really "clean" in my opinion : QString password = "yourRootPassword"; //could be asked with QInputDialog::getText(...) QString cmd = QString("sudo -S kextunload -b %1 > /dev/null").arg(driverName); FILE *pipe = popen(cmd.toStdString().c_str(), "w"); if(pipe != nullptr) { fprintf(pipe, "%s\n", password.toStdString().c_str()); if (ferror(pipe)) { qDebug() << "Failed to write to pipe"; } else { qDebug() << "Written to pipe"; } } else { qDebug() << "Failed to open pipe"; } qDebug() << "Pipe returned : " << pclose(pipe); I don't know how to use the Apple method linked by SGaist...
    • UNSOLVED how to feed data to Qt creator ( plugin development )
      General and Desktop • qtcreator plugin qprocess c++11 • • Qjay  

      4
      0
      Votes
      4
      Posts
      638
      Views

      thanks !! . I will look into both of them
    • SOLVED Qprocess not taking proper arguments
      General and Desktop • qt creator qprocess qtcore • • Qjay  

      10
      0
      Votes
      10
      Posts
      1445
      Views

      You might have modified PATH in your terminal session only for example. Or you may have modified PATH in the Run part of the Project panel.
    • SOLVED Problems with providing arguments to QProcess
      General and Desktop • qprocess desktop qt4 qstringlist • • Thanos  

      6
      0
      Votes
      6
      Posts
      4417
      Views

      @Thanos thanks for your feedback. So please mark this topic as SOLVED now.
    • UNSOLVED Communicating with Eternal C++ Project using QT Widgets Application
      Tools • qt creator qwidget cmake qprocess external proces • • Ghaas  

      2
      0
      Votes
      2
      Posts
      625
      Views

      Hi and welcome to devnet, You should take a look at the various IPC options provided by Qt.
    • UNSOLVED Web server started through QProcess is unable to receive GET requests
      General and Desktop • qprocess server http get environment • • Red Baron  

      22
      0
      Votes
      22
      Posts
      2925
      Views

      IIRC, you have QTest;:wait for that kind of stuff.
    • UNSOLVED QProcess: start a compiled c program and output to textBrowser in Linux
      General and Desktop • linux qprocess execute c program textbrowser • • Naim  

      13
      0
      Votes
      13
      Posts
      2896
      Views

      @Naim Use http://doc.qt.io/qt-5/qprocess.html#readyReadStandardOutput and http://doc.qt.io/qt-5/qprocess.html#readyReadStandardError to get notifications each time the process writes something to stdout or stderr and read it using http://doc.qt.io/qt-5/qprocess.html#readAllStandardOutput and http://doc.qt.io/qt-5/qprocess.html#readAllStandardError. Do not call waitForFinished, just make sure your proc does not go out of scope (make it class member).
    • SOLVED Try to get qprocess output
      General and Desktop • python qprocess ubuntu • • gizalp  

      2
      0
      Votes
      2
      Posts
      1042
      Views

      @gizalp Why do you think python (or anything else) is going to open any terminal window? And what OS are you on anyway? For QProcess:setProgram you should have process.setProgram("python");, only. But in this case I think it's getting overridden by your process.start("python test.py"); so it doesn't matter, but it's wrong. If you want to grab a sub-process's output, you have to handle QProcess::readyReadStandardOutput(), and in there something like QByteArray QProcess::readAllStandardOutput(), if that's what you mean by "How can I get the 'Hello' output?". How this relates to Trying to implement thumbnail list I have no idea....
    • SOLVED Qt Signal Slot
      General and Desktop • python qprocess signal&slot • • gizalp  

      6
      0
      Votes
      6
      Posts
      1525
      Views

      @gizalp said in Qt Signal Slot: @mostefa Thanks, that fixed my problem! You are welcome =)
    • SOLVED QProcess VS Qt-Solutions for daemon-service app
      General and Desktop • linux qprocess service windows desktop daemon • • ainu  

      7
      0
      Votes
      7
      Posts
      3284
      Views

      @kshegunov I see, now i understand. Thank you for your help and for your patience.
    • UNSOLVED QStringList destroy my Voice Command , what is wrong?
      General and Desktop • qprocess speech qstringlist qp • • patrik08  

      2
      0
      Votes
      2
      Posts
      516
      Views

      You can't read from a finished program. you have to connect to readyRead(); replace process->start(cmd,comandlist,QIODevice::ReadOnly ); if (!process->waitForFinished()) { lstr = QString(); } else { lstr = QString(process->readAll().constData()); } return lstr; with QObject::connect(process,&QProcess::readyReadStandardOutput,[&lstr,process]()->void{lstr.append(QString::fromLatin1(process->readAllStandardOutput()));}); process->start(cmd,comandlist,QIODevice::ReadOnly ); if (process->waitForFinished()) return lstr; return QString();
    • SOLVED QProcess::execute capture output
      General and Desktop • qprocess execute • • Jan-Willem  

      13
      0
      Votes
      13
      Posts
      18856
      Views

      @SGaist Good one! Though I had to use the C++11 version since C++14 is still in Debian Sid. // C++11 connect(process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, &MainWindow::close); For those who want to know, this is the C++14-version: // C++14 connect(process, qOverload<int, QProcess::ExitStatus>(&QProcess::finished), this, &MainWindow::close); Since the actual problem of this thread is solved, I will mark this thread as solved tomorrow. In the mean time comments on the above code can be made.
    • SOLVED Qt not reading shell variables
      General and Desktop • qprocess bash qgetenv shell variables • • Jan-Willem  

      7
      0
      Votes
      7
      Posts
      3431
      Views

      Well, actually it does work! But if bash is not running interactively, it won't read the .bashrc where the shell-variables are stored. So I did the following: sh.start("bash -i"); // the -i tell bash to run interactively if(sh.waitForStarted()) sh.write("printenv JAVA_HOME"); // or sh.write("echo $JAVA_HOME") sh.closeWriteChannel(); In case you were wondering, I connected the QProcess::finished signal to a slot where the QProcess::readAllStandardOutput is put in a QPlainTextEdit. The QProcess::processEnvironment is not updated however. Even if I try to export JAVA_HOME with sh.write("export JAVA_HOME"). While that is not what I expected, I now can find the local shell-variables. So I will mark this problem as solved. Thanks!
    • UNSOLVED Perl Script Behaves Differently When Launched from QProcess in GUI than on Command Line
      General and Desktop • qprocess command line prel • • DougyDrumz  

      2
      0
      Votes
      2
      Posts
      662
      Views

      Can you share the QProcess code you have written to execute the script ?
    • UNSOLVED reading and writing to QProcess in Qt Console Application
      General and Desktop • qtcreator qt 5.7 qprocess terminal • • CybeX  

      2
      0
      Votes
      2
      Posts
      3145
      Views

      @CybeX You already asked more or less the same question in another thread. In that another thread you was tolled to use the assynchronous API (there was even code for you). You should not try to do it in synchronous way, you are working against Qt. Use signals and slots. https://forum.qt.io/topic/75454/qprocess-readall-and-qprocess-readallstandardoutput-both-return-an-empty-string-after-qprocess-write-is-run/6
    • SOLVED QProcess::readAll and QProcess::readAllStandardOutput both return an empty string after QProcess::write() is run
      General and Desktop • qtcreator qt 5.7 qprocess readline stdio • • CybeX  

      14
      0
      Votes
      14
      Posts
      11778
      Views

      @JonB I don't know why this example does the output like this....
    • Send arrow keys via QProcess in any platform
      General and Desktop • linux qprocess windows 7 key arrowkeys • • Mark81  

      11
      0
      Votes
      11
      Posts
      4307
      Views

      @VRonin said in Send arrow keys via QProcess in any platform: @Mark81 Then do you really need Qt? there are already mature tools to do those kind of things, for windows: http://ahkscript.org/ and for linux: http://www.semicomplete.com/projects/xdotool/ I don't need Qt for this. But I have a quite large application that does a lot of things. One of those, is to launch external applications and send them keystrokes as you would type in front of a keyboard.
    • SOLVED QProcess buffers question
      General and Desktop • qprocess • • Jedd  

      3
      0
      Votes
      3
      Posts
      651
      Views

      Thanks! Marking solved.
    • UNSOLVED running apt-get by using Qt (QProcess)
      General and Desktop • qprocess ubuntu apt-get • • aghict  

      3
      0
      Votes
      3
      Posts
      824
      Views

      How can I fix this problem?