Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QProcess can't read/write to some console applications?
QtWS25 Last Chance

QProcess can't read/write to some console applications?

Scheduled Pinned Locked Moved General and Desktop
qprocessconsolepipingredirect
4 Posts 2 Posters 2.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    r.kull
    wrote on 8 Jun 2015, 07:50 last edited by
    #1

    Hello all!
    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:
    https://msdn.microsoft.com/en-us/library/windows/desktop/ms682499(v=vs.85).aspx
    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?

    // Robert

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 8 Jun 2015, 22:30 last edited by
      #2

      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 ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • R Offline
        R Offline
        r.kull
        wrote on 9 Jun 2015, 06:12 last edited by
        #3

        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?

        Thanks!
        // Robert

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 9 Jun 2015, 21:59 last edited by
          #4

          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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          4/4

          9 Jun 2015, 21:59

          • Login

          • Login or register to search.
          4 out of 4
          • First post
            4/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved