1

I want to create a process under QProcess with console show and acccess STDIN and STDOUT streams.

my code:

QProcess *p1 = new QProcess(this);
p1->start("cmd.exe");

if I want to show console I must use startDeatached() function, but by using this, I lost my STDIN/OUT access in my program. if I want to have access these, I dont have my console show!!!??? help me tanx.

QCoder
  • 79
  • 1
  • 6
  • "show!!!??? help me tanx." - Seriously? Is this your writing style? – sashoalm Oct 02 '14 at 12:20
  • I'm not an American person, My English is poor, I know this. If you can answer, do it... – QCoder Oct 02 '14 at 12:24
  • That's OK, neither am I, I learned English at school. But I don't think the !!!??? is due to bad English, or "help me tanx". I think it's more like the written equivalent of gutter slang. To tell you the truth this manner of speaking puts me off to the point of not wanting to help even if I can. So to answer your "If you can answer, do it..." - no I won't. – sashoalm Oct 02 '14 at 12:31
  • 1
    Post comments is not a good place for these conversations. here is a scientific place to answer the questions. If you could, you've done. – QCoder Oct 02 '14 at 12:41
  • 1
    read [documentation first](http://qt-project.org/doc/qt-5/QProcess.html#communicating-via-channels) before asking question here! When you read it if something is not clear ask question again. – Marek R Oct 02 '14 at 12:59
  • To me the question is very clear. Not sure if what the OP wants is possible though. – drescherjm Oct 02 '14 at 13:15
  • To solve this you may need to create a console based launcher application that starts detached and communicates with your application through networking. The purpose of this launcher is to start the console application (this time attached) you want capturing its stdin/stdout echoing the stdout to the screen and performing the two way communication to your main application. – drescherjm Oct 02 '14 at 13:25
  • Related quiestion: http://stackoverflow.com/questions/22574867/how-to-read-stdout-stderr-from-detached-qprocess ? – vahancho Oct 02 '14 at 13:29
  • Did you thought about creating window (widget) which will show contents of stdout of subprocess and look like a console? – Marek R Oct 02 '14 at 13:42
  • That is a good point. Does the OP really need a console window? I mean it is pretty easy to display the output of a console application in a Qt widget and still have access to stdin/stdout with QProcess. I do that for several of my applications. – drescherjm Oct 02 '14 at 13:50
  • Yes Marek R , I read the documents completely, but I didn't find my solution. I tried to simulate command prompt like cmd.exe, but I don't find a clear code for do some thing like this. and dear drescherjm I know your word, but my employer makes me to show him console by all console features. – QCoder Oct 04 '14 at 05:51

1 Answers1

1

after more investigations, I did not find my exact answer. But I did a quick trick (kalak rashti) for this problem. I used a QTextEdit custom class to simulate some thing behaves like console. frome this link: https://code.google.com/p/qterminalwidget/source/browse/trunk/ with some changes for my purpose.

QCoder
  • 79
  • 1
  • 6