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 .
相关问题
- QML: Cannot read property 'xxx' of undefin
- QTextEdit.find() doesn't work in Python
- QT Layouts, how to make widgets in horizontal layo
- QT GUI freezes even though Im running in separate
- QGraphicsView / QGraphicsScene size matching
相关文章
- ubuntu20.4中c#通过c++库调用python脚本
- Qt槽函数自动执行多遍
- Is there a non-java, cross platform way to launch
- How to get a settings storage path in a cross-plat
- Why doesn't valgrind detect a memory leak in m
- QTreeView remove decoration/expand button for all
- qt界面拥挤
- how do I correctly return values from pyqt to Java
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 thereadData()
andwriteData()
(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.An alternative: Tcl/TK
Unless you have good reason to use QT you might find it easier to use Tcl/Tk. Tcl was designed from the ground up for wrapping scripting and GUI facilities around existing C programs and is by far the easiest way to do this. It supports quite a few different ways to integrate C code and Tk (the GUI toolkit shipped with Tcl/Tk) is quite concise to program and very simple to learn (think: one 2 hour lab in a CS paper).
Tcl integration features:
Tcl can open a full-duplex pipe to the program and communicate down the pipe. At a guess this is probably the best option for you.
You can use fork/exec to run the program, passing command line arguments.
You can also embed the Tcl interpreter in your C program; the API for doing this is dead simple.
Tcl has API's (also quite simple) for extending the interpreter with new commands.
Probably one or two other ways that I can't remember off the top of my head.
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).
I think you have to put the following entries in your
.PRO
file :You can then create a Window in Qt, and you'll have your main window next to a console !
Example :
Hope it helps a bit !
from http://www.qtcentre.org/threads/33506-where-is-cout-in-Qt-Creator
first add
to your .pro file
second use
For me it works this way.
Have fun