[Qt-interest] Custom QGLWidget as viewport for QGraphicsView
Josiah Bryan
jbryan at productiveconcepts.com
Thu Mar 4 19:49:11 CET 2010
Hey all -
How can I do my own performance sensitive painting as the background for
a QGraphicsView? What, drawBackground() you say? Ummm...performance is
terrible with that. Specifically, low-latency updates are very difficult
to achieve. For example, when trying to render a video stream from a
live camera (from a PCI capture card) in drawBackground(), the latency
is quite noticeable - I'd say anywhere from 100ms - 300ms latency (e.g.
for lip sync with audio or eye blinking.)
Now, the same video stream rendered to a dedicated widget derived from
QGLWidget renders with virtually no perceptible latency - I'd say less
than 100ms if I had to guess. (How *does* one quantifiable measure real
time latency like that - e.g. event happens in front of camera to the
time it displays on screen? Right now, I test it by seeing if I can see
my self blink on screen - silly, I know - but it's fairly good judge of
latency.)
However, trying to render in drawBackground() gives terrible performance
- less than 1 frame every several seconds! I've optimized QGraphicsView
using every possible optimization I can think of - setCachdeMode to
none, render hints, viewport update mode, optimization flags, and of
course, setting a plain QGLWidget as a viewport - nothing speeds up
rendering. Even a plain repaint() or update() does NOTHING - I have to
call scene()->update() to get the drawBackground() method to be called
again.
My last thought is to try a custom QGLWidget (the one that works fine)
as the viewport for the QGraphicsView so that QGV can draw the items on
top of the QGLWidget - but that doesn't seem to do anything. The custom
QGLWidget never gets to paint anything.
Any ideas or advice?
Thanks!
-josiah
--
-=-=-=-=-=-=-=-=-=-=-=-=-
Josiah Bryan
Productive Concepts, Inc.
jbryan at pciint.com
(765) 964-6009, ext. 224
More information about the Qt-interest-old
mailing list