PDA

View Full Version : How to write qt4 gui up to the existing console



binaural
11th May 2009, 10:36
Hi,

I'm new to QT problematics and this could be maybee easy to answer. I writtenin C console app. for uploading FW to some HW but I wouldlike to add some gui for users. Console app. using libusb. I don't want to have 2 separate apps (console and gui) but just need gui for controlling console. Is there any tutorial or good example how to do this in QT?

Thanks

faldzip
11th May 2009, 11:06
look at QProcess docs. You can run process with that class and communicate with it writing and reading in similar way to writing and reading file (both QFile and QProcess are subclasses od QIODevice).

binaural
16th June 2009, 13:30
Hi,

thanks for response. I try to use QProcess but I got very strange behaviour.
I try to run dmesg from QT and it works fine (I got an output to TextEdit). When I run my external program (which printout every second something to stdout) I never get signal for reading some data from stdout.

Code snippet:

process.setReadChannel(QProcess::StandardOutput);
connect(&process, SIGNAL(readyReadStandardOutput()), this, SLOT(updateOutput()));
//process.start("dmesg -s10");
process.start("/home/marek.nandra/projects/qt/test_app/gui/process_test/test");

Am I doing something wrong or should I wait for something else?

Thanks in advance,

Marek

wysota
16th June 2009, 14:31
Most likely you are creating the QProcess object on the stack and it gets destroyed once you leave the method you created it in. Create the object on heap instead.

It's the same problem as here:
http://www.qtcentre.org/forum/faq.php?faq=qt_general_category#faq_qt_stack_creat ed_widgets

binaural
16th June 2009, 14:44
Problem was different. In test program is necessary to call fflush(stdout) and it works fine then. Hope this will help someone :). Thanks for help.