title: VTK Image slices to volume (C++)
body: <p>I'm trying to display a volume slices-composed in QT5+VTK 7.0.0. However, I don't know why using <strong>vtkImageSlice</strong>+<strong>vtkImageStack</strong> only shows me <strong>one</strong> slice instead of <strong>five</strong> slices. This is the code I'm using it:</p>
  <pre class="lang-cpp prettyprint-override"><code>/*This function receives an ultrasound image from network.
  The function is working fine if we display the 2D images,
  but I want to stack a bunch of images in a volume.
  The imageStack at the end always keeps one image only.*/
  void WDisplay::Disp(QImage b)
  {
      // qimagevtk is a vtkSmartPointer&lt;vtkQImageToImageSource&gt; type
      qimagevtk-&gt;SetQImage(&amp;b);
      qimagevtk-&gt;Update();
      // imageSliceMapper is a vtkSmartPointer&lt;vtkImageSliceMapper&gt; type
      imageSliceMapper-&gt;SetInputData(qimagevtk-&gt;GetOutput());
      // imageSliceMapper is a vtkSmartPointer&lt;vtkImageSlice&gt; type
      imageSlice-&gt;SetMapper(imageSliceMapper);
      imageSlice-&gt;GetProperty()-&gt;SetOpacity(.5);
  
      // Stack
      // vtkSmartPointer&lt;vtkImageStack&gt;
      imageStack-&gt;AddImage(imageSlice);
      if(!(idx&lt;5)) //idx initialized at zero in the constructor
      {
          // m_renderer ---&gt; vtkRenderer
          m_renderer-&gt;AddViewProp(imageStack);
          m_renderer-&gt;Render();
          // wvtk ---&gt; QVTKWidget
          wvtk-&gt;GetInteractor()-&gt;Render();
          idx = 0;
      }
      else
          idx++;
  }
  </code></pre>
  <p>This is the output (screenshot) I got when I run the function:
  <img src="https://i.imgur.com/HAdvpF9.png?1" alt="screenshot" /></p>
  <blockquote>
  <p>Every vtk object was created in the constructor using <strong>vtkSmartPointer&lt;<em>vtk object type</em>&gt;::New()</strong>. I hope anyone can help me. Thank you.</p>
  </blockquote>