<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <span id="result_box" class="" lang="en"><span class="hps">Hello</span><span>,</span>
      <br>
      <br>
      <span class="hps">I'm</span> <span class="hps">currently</span> <span
        class="hps">trying to</span> <span class="hps">integrate</span>
      <span class="hps">a</span> <span class="hps">vtk</span> <span
        class="hps">view in a</span> <span class="hps">QGraphicsScene</span> <span
        class="hps"></span></span><span id="result_box" class=""
      lang="en"><span class="hps"><span id="result_box" class=""
          lang="en"><span class="hps">using</span></span></span>  <span
        class="hps">the QVTKGraphicsItem</span><span>.</span> <span
        class="hps">When it</span> <span class="hps">works perfectly</span>
      <span class="hps">under</span> <span class="hps">linux</span> <span
        class="hps">or</span> <span class="hps">mac</span><span>,</span>
      <span class="hps">I encounter</span> <span class="hps">some
        difficulties</span> on <span class="hps">windows</span><span>.</span>
      <span class="hps">Note that I</span> <span class="hps">used</span>
      <span class="hps">VTK</span> <span class="hps">5.10 and</span> <span
        class="hps">Qt4.8.5, and also tested the </span></span><span
      id="result_box" class="" lang="en"><span class="hps"><span
          id="result_box" class="" lang="en"><span class="hps">master of
            the </span></span>VTK git repository .<br>
        <br>
      </span></span><br>
    <span id="result_box" class="" lang="en"><span class="hps">My
        problem is first that I</span> <span class="hps">can not</span>
      <span class="hps">execute</span> <span class="hps">the</span> <span
        class="hps">example</span> <span class="hps">'qtgraphicsView</span>'
      from <span class="hps">VTK</span><span>, I get</span> <span
        class="hps">a</span> <span class="hps">crash</span> <span
        class="hps">at</span> <span class="hps">line 115 of</span> <span
        class="hps">QVTKGraphicsItem.cxx</span><span class="">:</span></span>
    <blockquote><i><span id="result_box" class="" lang="en"><span
            class="hps">void QVTKGraphicsItem::MakeCurrent()</span></span></i><i><br>
      </i><i><span id="result_box" class="" lang="en"><span class="hps">{</span></span></i><i><br>
      </i><i><span id="result_box" class="" lang="en"><span class="hps"> 
            mContext->makeCurrent();</span></span></i><br>
      <br>
    </blockquote>
    This seems to be due to the fact that under windows, calling
    QGraphicsView::setViewport(QWidget *w) with w being a QGLWidget,
    invalidates the current QGLContext if any, and then end up on a
    crash if one tries to call create or makeCurrent on it. <br>
    <br>
    A simple workaround to this behavior can be to change the three
    first line of the constructor of GraphicsView in GraphicsView.hpp
    from the example, in order to get the QGLContext after calling the
    setViewport method : <br>
    <br>
    <blockquote><i>class GraphicsView : public QGraphicsView</i><i><br>
      </i><i>{</i><i><br>
      </i><i>  public:</i><i><br>
      </i><i>    GraphicsView()</i><i><br>
      </i><i>    {</i><i><br>
      </i><i>//      mCtx = new QGLContext(QGLFormat());</i><i><br>
      </i><i>//      mWidget = new QVTKWidget2(mCtx);</i><i><br>
      </i><i>//      this->setViewport(mWidget);</i><i><br>
      </i><i><br>
      </i><i>      mWidget = new QVTKWidget2;</i><i><br>
      </i><i>      this->setViewport(mWidget);</i><i><br>
      </i><i>      mCtx =
        const_cast<QGLContext*>(mWidget->context());</i><br>
      <br>
    </blockquote>
    This works like a charm with linux (<span id="result_box"
      class="short_text" lang="en"><span class="hps">no significant</span>
      <span class="hps">changes</span></span> with the original) and
    fixes the crash with windows but results in terrible performance,
    (try to interact wit the treeRingItem for example.) <br>
    <br>
    My questions are, is there anybody on this mailing list having the
    same issues, Does it comes from a bad configuration, or is it a VTK
    problem ? If it is a VTK problem does someone have any idea on how
    to solve it ? <br>
    <br>
    Thanks !<br>
    <br>
    rdebroiz.
  </body>
</html>