i have a console application that generated from bison (a parser) and i want to build a simple gui for it so i can send input from this gui to the console and get output from the console into the gui . i tried to do that using java process class but it doesnt work for me , please help me to do that using qt .
It depends on the complexity of the data you want to feed in/out of your console application.
Low complexity Use some command switches that you pass from your Qt GUI to your console application. Look at the QProcess class documentation.
High complexity I would go with an RPC-like solution. Look at the QtDBus documentation (Linux/Unix only).
Note: I made the assumption that you want to keep your generated bison parser apart from your Qt GUI (in case you need the regenerate it again).
from http://www.qtcentre.org/threads/33506-where-is-cout-in-Qt-Creator
first add
CONFIG += console
to your .pro file
second use
#include <stdio.h>
QTextStream out(stdout);
out << QString("Some text");
For me it works this way.
Have fun
Keep your console and your graphical application, two separated applications. You already have the console one, so let's see how to make the other:
Make a normal GUI application in Qt and, using the QProcess
class, call your console application. Use the readData()
and writeData()
(and similar) methods of this class to read from standard output and write to standard input of your console application.
Check the QProcess
documentation for details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With