Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using qt : How To Build a Gui OnTop Of a Console Application?

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 .

like image 220
Radi Avatar asked Feb 03 '10 16:02

Radi


3 Answers

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).

like image 188
Etienne Savard Avatar answered Oct 24 '22 13:10

Etienne Savard


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

like image 35
zac Avatar answered Oct 24 '22 14:10

zac


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.

like image 24
Silas Avatar answered Oct 24 '22 14:10

Silas