<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-15">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Hello,<br>
    <div class="moz-forward-container"><br>
      i am having problems using the VTK stuff in a QT QGraphicsview
      project. I dont use any normal QT GUI classes, just the opengl
      rendered stuff with QGraphicsView and QGraphicsScene. VTK has
      created the QVTKGraphicsItem class for that reason, but it doesnt
      work right:<br>
      <br>
      <img alt="ChartPicture.jpg"
        src="cid:part1.03010105.08020908@whosme.de" height="341"
        width="1146"><br>
      <br>
      The Chart will appear, but as soon as i click anywhere in the
      chart (or using the mousewheel on top of the chart), the content
      will disappear :( The contents wont come back, except when i
      resize the QVTKGraphicsItem, then it repaints and the content is
      there again. But i would like to get the events/interaction right,
      so that i can zoom into the chart. Is this a bug?<br>
      <br>
      Here is somekind of the minimal code of the problem:<br>
      <br>
      <br>
      #include "vtkSmartPointer.h"<br>
      #include "QVTKGraphicsItem.h"<br>
      #include "vtkChartXY.h"<br>
      #include "vtkTable.h"<br>
      #include "vtkFloatArray.h"<br>
      #include "vtkPlot.h"<br>
      #include "vtkRenderer.h"<br>
      #include "vtkNew.h"<br>
      #include "vtkGenericOpenGLRenderWindow.h"<br>
      #include "vtkContextActor.h"<br>
      #include "vtkContextScene.h"<br>
      <br>
      #include &lt;qgraphicsscene&gt;<br>
      #include &lt;qgraphicsview&gt;<br>
      #include &lt;qapplication&gt;<br>
      <br>
      int main(int argc, char* argv[])<br>
      {<br>
          //First create QT QGraphicsview with QGraphicsScene<br>
          //--------QT---------------<br>
          QApplication a(argc, argv);    <br>
          QGraphicsView v;<br>
          QGraphicsScene s;<br>
          v.setScene(&amp;s);<br>
          QGLWidget glwidget(QGLFormat::defaultFormat());<br>
          QGLContext context( QGLFormat::defaultFormat());<br>
          glwidget.makeCurrent();<br>
          v.setViewport(&amp;glwidget);<br>
      <br>
          //Now create a chart with openglrenderer<br>
          //---------vtk ------------<br>
      <br>
          QVTKGraphicsItem* item = new
      QVTKGraphicsItem(&amp;context);    <br>
          item-&gt;setGeometry(10,20,500,300);<br>
              <br>
          vtkNew&lt;vtkChartXY&gt; chart;<br>
          vtkNew&lt;vtkContextScene&gt; chartScene;<br>
          vtkNew&lt;vtkContextActor&gt; chartActor;<br>
              <br>
          chartScene-&gt;AddItem(chart.GetPointer());<br>
          chartActor-&gt;SetScene(chartScene.GetPointer());<br>
      <br>
          vtkNew&lt;vtkTable&gt; table;<br>
          vtkNew&lt;vtkFloatArray&gt; arrX;<br>
          arrX-&gt;SetName("X");<br>
          table-&gt;AddColumn(arrX.GetPointer());<br>
          vtkNew&lt;vtkFloatArray&gt; arrV;<br>
      <br>
          arrV-&gt;SetName( "bla" );<br>
          <br>
          table-&gt;AddColumn(arrV.GetPointer());    <br>
      <br>
          auto numPoints = 5;<br>
          table-&gt;SetNumberOfRows(numPoints);<br>
      <br>
          for (auto i = 0; i &lt; numPoints; ++i)<br>
          {<br>
              table-&gt;SetValue(i, 0, i);<br>
              table-&gt;SetValue(i, 1, i*2);<br>
          }<br>
      <br>
          vtkPlot *points = chart-&gt;AddPlot(vtkChart::BAR);<br>
          points-&gt;SetInput(table.GetPointer(), 0, 1);<br>
          points-&gt;SetColor(140, 10, 200, 255);<br>
          points-&gt;SetWidth(3.0);<br>
              <br>
          vtkSmartPointer&lt;vtkRenderer&gt; renderer =
      vtkSmartPointer&lt;vtkRenderer&gt;::New();<br>
          renderer-&gt;SetBackground(0.3, 0.3, 0.3);<br>
      <br>
          renderer-&gt;AddActor(chartActor.GetPointer());<br>
          chartScene-&gt;SetRenderer(renderer.GetPointer());<br>
      <br>
          vtkSmartPointer&lt;vtkGenericOpenGLRenderWindow&gt;
      renderWindow =
      vtkSmartPointer&lt;vtkGenericOpenGLRenderWindow&gt;::New();       
                  <br>
          renderWindow-&gt;AddRenderer( renderer );<br>
                  <br>
          item-&gt;SetRenderWindow( renderWindow.GetPointer() );<br>
      <br>
          //now add the vtk item to the qgraphicsscene and show it:<br>
          //----------QT-------<br>
          s.addItem(item);<br>
          <br>
          v.show();<br>
          a.exec();<br>
      }<br>
      <br>
      Best regards,<br>
      Matthias Thurau<br>
      <br>
    </div>
    <br>
  </body>
</html>