PDA

View Full Version : updating waterfall QwtSpectrogram



tnorthardt
1st November 2012, 21:24
Hi all, I'm stuck after implementing a waterfall with QwtSpectrogram. I've had a look at the other posts and I'm still stumped.

I have a button that when clicked calls ui->myQwtPlot->replot(); and my spectrogram updates as many times as I click the button with almost no delay. However, if I place the replot(); call in a FOR loop under the button's callback, the spectrogram will not update. I included a sleep(1) in the FOR loop just in case there was some odd delay.

Still no luck.

Any ideas?

Thanks,
Tom

Uwe
2nd November 2012, 07:49
Widgets are repainted inside of its paintEvent only ( beside a special mode that is available on X11 only ). Thus QwtPlot::replot doesn't repaint the plot - it adds events to to the event queue that have no effect as long as the event queue is not processed.

You could add QApplication::processEvents() or QApplication::sendPostedEvents() to your button click handler.

But when using QApplication::sendPostedEvents() note that QwtPlot is a composite widget and you have to process the events for all children of the plot. Also note that processing an event might initiate other events that also need to be processed.

HTH,
Uwe

tnorthardt
2nd November 2012, 14:59
Hi Uwe, I'm very appreciative you are so active on the forum.

I added the line you suggested and my immediate problems have been resolved :-) . I understand being leary about requesting that all the events be processed. I'm not sure what effect this will have on my long term development - I will have to figure it out. But , in any event, you're post was very helpful!

Best,
Tom