QProcess can't read/write to some console applications?
r.kull last edited by
I have been stuck with a problem for a while now, googled around but can't find the problem. So now I hope that someone here can help me!
I'm writing an application that is supposed to be communicating with another console application (non Qt). If I just open the external console application, it works fine. But when I use QProcess to start the external application, I'm not able to write to it. I can see that the correct number of bytes are written but still nothing in return. I can use my Qt application to read/write to e.g. Scilab console with no problem.
A colleague used C# to do what I want with success. He then had to set the redirection flags to "true" to be able to read/write to the external console app. (I know nothing about C# but this is what he told me).
Also, I copied this example from the MSDN site:
which (kind of) works. I'm able to write and read to/from the external console but the order of the read contents are a bit messed up (some stuff gets duplicated, wrong order etc..). This makes it hard to search for starts and ends of answers from the external console.
If anyone has any clue of how to fix my problem, please help me! What options do I have?
Hi and welcome to devnet,
Which version of Qt are you using ? On which version of Windows ? What console application is giving you hard time ?
r.kull last edited by
Thank you! And thank you for responding this quickly! :)
I'm using Qt 5.4 on Windows 7 Enterprise SP1. The Console Application is a company internal application developed by some guys in India who, unfortunately, are hard to reach...
BUT, however, I got it working yesterday! I used the MSDN example in my previous post which kind of worked and modified the way my application read the console. It might not be the most elegant solution but at least it works well enough for me. :)
It seemed that the console application needed a named pipe to enable the communication in between my app and the console. I would still like to know why this is (just out of curiosity if anyone know). I also read that one could use QLocalServer/QLocalSocket to do named piping using Qt. Is that possible with an arbitrary external console?
If it needs a named pipe then you should ask the author.
AFAIK, you should be able to connect to a named pipe using QLocalSocket