PDA

View Full Version : Qt containers



Ashish Bhasin
11th April 2014, 17:43
I made a project in Qt, I took a listwidget container and a pushbutton and on the click of a button , i am filling dat listwidget using additem action, i am filling 100 chars in 1 click using a loop, now what hapng is that when i click on the buton i see those 100 chars but i want a continuous o/p like the one console provides i.e. printing of characters one by one, then i used sleep function after the line ui->listwidget->additem(char), then it starts sleeping for the gien time on the mainwindow show and still it gives 100 chars in one time, what is the solution:confused:

boudie
11th April 2014, 19:01
Use a QTimer.

Ashish Bhasin
13th April 2014, 11:47
but my input is variable and Qtimer will print the same input again and again

anda_skoa
13th April 2014, 13:45
What boudie meant is that you could use a timer to advance through your input instead of a loop.

Basically you would be replacing a tight for/while loop with processing one input at each iteration of the event loop.

Your current tight loop processes all input items in one go without giving the listview a chance to update its visualisation. Which results in the observed behavior of all items appearing in one go.
By returning to the event loop each time you've added an item you allow the view to update its drawing for each item add.

Cheers,
_

Ashish Bhasin
14th April 2014, 11:58
Yeah thanks previous issue solved but now a new one, using Qtimer, i can print about 5000 statements in a minute without giving any delay in the timer start event but the speed of my input is around 100 times more than that i.e. around 5,00,000 statements per minute

Added after 4 minutes:

i better make my question simple, i want to flush the output of a c file in gui and the output will be half a million statements per minute and i want to see them in GUI the same way we see them on a console, how should i proceed

anda_skoa
14th April 2014, 12:50
A list widget might be the wrong widget for that.

Have you tried a QTextBrowser?

Cheers,
_