[Solved] Writing data to C execution file from QT Gui program
-
hai,
In my application I want to send data from gui running program to C.exe file
I tried like In c file I write a program to taking the I/p from scanf() and In Qt I call QProcess function. but it is giving the output as
"The program has unexpectedly finished."Is my thought was wrong?
If any solution is there then please explain me -
With console input, or using DBus, sockets, or just by setting the command line arguments (that's enough in some cases).
-
Using file is an option, but I wouldn't recommend it. Writing with one program and reading with the other might cause buffer overflows etc in your program. If there is data to be "transported" it might be a better option to use TCPIP connection to the home server. In Qt it is easy to setup and with signal/slots connections fast handling is achieved.
-
If you're one the same machine, you can have a look at "QLocalServer":http://qt-project.org/doc/qt-4.8/qlocalserver.html and "QLocalSocket":http://qt-project.org/doc/qt-4.8/qlocalsocket.html
And if you really want TCP/IP you have QTcpServer and QTcpSocket. Have a look at the examples provided along these classes, that will help you get started.
There is also QSharedMemory. Read all their docs to find what's the best solution for you.
-
C program and Qt both are on same machine only.
I have some doubt regarding using the server and socket programming in both C and QT,My c program will called by QT only and C program will run with QT in background, So can I use server and socket program or not?
If I use shared memory concept in QT then how can I get that data from shared memory in to C program?
-
You're not locked with Qt's IPC classes, you can use pure C IPC even with your Qt program.
By the way it's Qt, QT is for Apple's QuickTime :)