[vtkusers] Using vtkRenderWindow with QGraphicsView [Qt 4.4.1]

Prashanth Udupa prashanth.udupa at gmail.com
Thu Aug 28 15:07:27 EDT 2008


Hi Clinton,

I would recommend implementing a QPaintEngine for the QVTKWidget, instead of
> what you're trying to do.  Then it should simply be a matter of setting a
> QVTKWidget as the viewport of the QGraphicsView.



Hmmm... I did try something like that. I have a working vtkQtRenderWindow
for Qt 4.4; which we can set as viewport for QGraphicsView. But then I
wonder if the paintGL() of the viewport would blend well with the
paint-sequence of graphics view. I mean we would have two potential painting
sequences

- The viewport's paintGL() method
- QGraphicsView's drawBackground(), scene()->render() and drawForeground()

When we setViewport() another widget to QGraphicsView, we are basically
allowing QGraphicsView to deal with all events delivered to the viewport.

void QAbstractScrollArea::setViewport(QWidget *widget)
{
        // .........
        d->viewport->installEventFilter(d->viewportFilter);
        // .........
}

The viewportFilter sends all events from the viewport to the
QAbstractScrollArea::viewportEvent(), which would essentially call event
handlers in QGraphcisView to handle the event. This means that paintEvent of
the viewport, will be handled in the paintEvent() of QGraphicsView. This
means that the first paint-sequence (aka QGLWidget::paintGL()) will never be
called.

Which is why I think we should do the painting in drawBackground(), which is
a part of the second painting sequence; the one that actually gets executed.


I've done some experimenting with a QPaintEngine for QVTKWidget before, but
> I
> haven't done enough to get something to commit into the repository.  Do you
> want some of that code to play with too?



Thanks, that would be great :). You could send it to me or post it to the
list.

Thanks and Regards,
Prashanth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080829/b4bbac24/attachment.htm>


More information about the vtkusers mailing list