Shibli
Shibli

Reputation: 6149

Data transfer between Qt and a C++ code

I have a C++ code and now I am thinking to prepare a UI with Qt since its language is also C++. Before attempting to do that I wonder how can I transfer data between my code and UI code. I mean, I do not want to write variables to a textfile and let UI to read it. Instead I want this to be done internally. I know this is possible but dont know where to start. Any idea?

Upvotes: 0

Views: 730

Answers (2)

cgmb
cgmb

Reputation: 4424

For basic communication between a GUI processes and a command-line process, I'd use QProcess. It provides facilities for starting an executable with arguments, reading stdout & stderr, writing to stdin, and notification of program termination. It's cross-platform, and will work with just about anything designed for command-line interaction.

Upvotes: 0

Martin
Martin

Reputation: 4862

Qt has a Signal and Slot mechanism that is meant for this purpose. Take a look at the examples here http://qt-project.org/doc/qt-5.0/examples-widgets.html This also works if the Gui runs in a Separate Thread but be careful to get Threading and Signals and Slots right: http://labs.qt.nokia.com/2010/06/17/youre-doing-it-wrong/

Upvotes: 1

Related Questions