[vtkusers] QVTKWidget paintEvent

Leonardo M. Ramé l.rame at griensu.com
Mon Sep 27 10:51:23 EDT 2010


Thanks Sam, I tried this, but found two problems:

1) The mouse events are not catched by the interactor of
vtkImageViewer2. I mean, when I drag the mouse, it should do
window/level and after subclassing the mousePress/mouseRelease and
mouseMove events, it doesn't work anymore.

2) My drawing is flicking over the background image viewer, is there a
way to avoid flickering?.

-- 
Leonardo M. Ramé
http://leonardorame.blogspot.com

On 2010-09-24 10:32:15 -0400, (Samuel) Byeongjun Park wrote:
> You have to override the mouse events in your myWidget class,
> such as mousePressEvent(), mouseMoveEvent(), mouseReleaseEvent(),
> wheelEvent() and etc.
> and call update() there.
> If the painting job is heavy stuff, you would better to make conditional
> painting routine or merge them into VTK's rendering process using
> vtkPolyData (maybe with vtkCutter).
> 
> Sam.
> 
> -----Original Message-----
> From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On Behalf
> Of Leonardo M. Rame
> Sent: Friday, September 24, 2010 9:53 AM
> To: VTK Users
> Subject: [vtkusers] QVTKWidget paintEvent
> 
> Hi, can paint over a QVTKWidget, however my drawings are lost when I
> click on the widget or after setting a vtkImageViewer2 into it.
> 
> This is the code I use to paint over the QVTKWidget:
> 
> QPaintEngine * myWidget::paintEngine() const
> {
>   return QWidget::paintEngine();
> }
> 
> void myWidget::paintEvent(QPaintEvent * e)
> {
>   QVTKWidget::paintEvent(e);
>   QPainter paint(this);
>   paint.setPen(Qt::white);
>   paint.drawRect(5,5,10,10);
> }
> 
> How can I let my drawings repaint over the image viewer
> 
> -- 
> Leonardo M. Ramé
> http://leonardorame.blogspot.com
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers





More information about the vtkusers mailing list