PDA

View Full Version : Best way to display lots of data fast



New2QT
15th October 2008, 07:01
Hello,

I need to make a visual widget that will update data that arrives very quickly from a hardware device. This will be for Windows, Linux, and Mac Basically you can think of it as very similar to a terminal displaying data arriving on a serial port. The data will be displayed as text at the bottom of the widget. When new data arrives, the old data will be scrolled up and the new data painted to the bottom row.

In standard Windows programming this is simple, when data arrives you just scroll the window and redraw the bottom line. When a paint messgae comes in redraw all the data. I'm wondering if in QT it's better to use a QPainter or go the OpenGL route or perhaps sometihng else. My biggest concern initially was a comment in the help indicating that on a Mac you can't paint the widget outside of the paint event. This could be a problem as the paint event would have to be called every time the data arrived instead of simply scrolling the window and painitng the new area. There will be many of these Widgets in the application (maybe a hundred or so) but only a handfull will be visible at a time (though non-visible ones will still be processing incoming data) so efficiency is very important. The data that arrives for each widget will be handled in it's own thread.

So what are my options here, pros cons, etc?

Thanks

aamer4yu
15th October 2008, 07:27
Did you have a look at model-view-programming ??

fullmetalcoder
15th October 2008, 13:12
depending on what data you will actually display, the amount of data involved and how long you wish to keep the data available for view the "best" solution (if any) will vary.

A good start, if you're data can be displayed as text (and need not be editable) is a trimmed down text edit (start from a QAbstractScrollArea and store lines of text to display in a QStringList, possibly removing old entries when reaching a given size limit). The all you have to do is to implement a simple line by line paint eventwhich really isn't difficult (a simple for loops of drawText() calls with a bit of coordinates manipulation).

Uwe
15th October 2008, 13:36
My biggest concern initially was a comment in the help indicating that on a Mac you can't paint the widget outside of the paint event.
On X11 you can, on Windows and the Mac you can't.


So what are my options here, pros cons, etc?

You can download Qwt ( http://qwt.sf.net ). It has an example called realtime, that generates random values painting them incrementally in a scatter plot. Maybe this helps to get an idea what is possible. You can also build Qwt against Qt3, what is obviously faster.

Maybe have a look at QwtPlotCurve::draw ( qwt_plot_curve.cpp, line 483). It shows how you can transfer a paint operation into a paintEvent without repainting the complete widget. But don't expect such a solution being as fast as a thin wrapper around the native graphics system, what QPainter in Qt3 was.

Uwe

New2QT
16th October 2008, 23:46
Thanks all, this gives me plenty to get started with. :)