PDA

View Full Version : Howto convert console Application to QT UI - what's the concept?



KlausKoe
11th June 2010, 12:03
Hi,

I have to say that I am a complete Noob to UI programming. I prefere background development.

Anyway I have a console application which runs for 10min and has a lot of console text output. The application does what it should but if others want to use it it should be more user firendly. E.g. there are a lot of parameters which have to be change in source code currently.

That's why I want to add a UI and I chose QT.

But I've some problems understanding the concepts. To start I have created a small app with just one button and a plaintextedit (PTE).

In button->clicked() I can add another text line to the PTE.

But actually with the click of the button I want to run my core algorithm and want to send a lot of updates to the PTE. (use it as console).

So I added a 10000 time loop in button->clicked() and in each loop another line is added. I also added QCoreApplication::instance()->flush(); in each loop and hoped to see immediatelly updates.

But it only updates if clicked() is left.

How should it be done correctly? I think I miss something...

squidge
11th June 2010, 12:07
GUI will not be updated until your function returns, so you need to change your program completely. Put your algorithm in a thread, tell it to send a signal to your main thread everything time it has something to output and have your main thread to capture this signal and output text to PTE.