<div dir="ltr">I can see one thing missing, right of the bat. You need to do the following before QApplication in instantiated.<div><br></div><div><div class="gmail-line" style="font-stretch:normal;font-size:13px;line-height:1;font-family:monospace,fixed;min-height:13px;white-space:pre-wrap;word-wrap:break-word;padding-left:53px;padding-bottom:0px;margin:0px;color:rgb(0,0,0)"><b>QSurfaceFormat::setDefaultFormat</b>(format);</div></div><div><br></div><div>Utkarsh</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 1, 2017 at 1:49 PM, Olivier Commowick <span dir="ltr"><<a href="mailto:olivier.commowick@inria.fr" target="_blank">olivier.commowick@inria.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space">Hi everyone, <div><br></div><div>I have been struggling with using QVTKOpenGLWidget to display an image with the vtkImageViewer. My problem is basically that the image is loaded and everything created but it seems the rendering is never triggered and thus the display is black. </div><div><br></div><div>To summarize what I’ve done, I’ve created a vtkImageViewer3 which is the same as vtkImageViewer from VTK, only changing the vtkRenderWindow to be a vtkGenericOpenGLRenderWindow (required by the QVTKOpenGLWidget). I have then modified the ImageViewer example from VTK to match these new classes which gives the following code (see at the end). Oh, and I am using Qt5.7, and VTK 8.0 release.</div><div><br></div><div>Would anyone have any clue on what could make this work (i.e. actually render something and display it) ? </div><div><br></div><div>Thanks in advance</div><div>Olivier</div><div><br></div><div>——</div><div><br></div><div>Main.cxx code:</div><div><br></div><div>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#000080">#include</span><span style="color:#c0c0c0"> </span><span style="color:#008000"><QApplication></span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#000080">#include</span><span style="color:#c0c0c0"> </span><span style="color:#008000">"vtkImageViewer3.h"</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#000080">#include</span><span style="color:#c0c0c0"> </span><span style="color:#008000">"vtkRenderWindowInteractor.h"</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#000080">#include</span><span style="color:#c0c0c0"> </span><span style="color:#008000">"vtkRenderer.h"</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#000080">#include</span><span style="color:#c0c0c0"> </span><span style="color:#008000">"vtkPNGReader.h"</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#000080">#include</span><span style="color:#c0c0c0"> </span><span style="color:#008000">"QVTKOpenGLWidget.h"</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#000080">#include</span><span style="color:#c0c0c0"> </span><span style="color:#008000"><QSurfaceFormat></span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#808000">int</span><span style="color:#c0c0c0"> </span>main(<span style="color:#808000">int</span><span style="color:#c0c0c0"> </span>argc,<span style="color:#c0c0c0"> </span><span style="color:#808000">char</span>**<span style="color:#c0c0c0"> </span>argv)</pre>
<pre style="margin-top:0px;margin-bottom:0px">{</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">    </span><span style="color:#800080">QSurfaceFormat</span><span style="color:#c0c0c0"> </span>format<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span><span style="color:#800080">QVTKOpenGLWidget</span>::<wbr>defaultFormat();</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">    </span>format.setSamples(<span style="color:#000080">0</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">    </span><span style="color:#800080">QApplication</span><span style="color:#c0c0c0"> </span>app(argc,<span style="color:#c0c0c0"> </span>argv);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">    </span><span style="color:#800080">QVTKOpenGLWidget</span><span style="color:#c0c0c0"> </span>widget;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">    </span>widget.setFormat(format);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">    </span>widget.<span style="font-style:italic">setEnableHiDPI</span>(<span style="color:#808000">true</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">    </span>widget.resize(<span style="color:#000080">256</span>,<span style="color:#000080">256</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">    </span><span style="color:#800080">vtkPNGReader</span>*<span style="color:#c0c0c0"> </span>reader<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span><span style="color:#800080">vtkPNGReader</span>::New();</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">    </span><span style="color:#800080">std</span>::<span style="color:#800080">string</span><span style="color:#c0c0c0"> </span>fname<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span>argv[<span style="color:#000080">1</span>];</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">    </span>reader-><span style="font-style:italic">SetFileName</span>(fname.c_<wbr>str());</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">    </span><span style="color:#800080">vtkImageViewer3</span>*<span style="color:#c0c0c0"> </span>image_view<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span><span style="color:#800080">vtkImageViewer3</span>::New();</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">    </span>image_view-><span style="font-style:italic">SetInputConnection</span><wbr>(reader->GetOutputPort());</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">    </span>widget.SetRenderWindow(image_<wbr>view-><span style="font-style:italic">GetRenderWindow</span>());</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">    </span>image_view->SetupInteractor(<wbr>widget.<span style="font-style:italic">GetRenderWindow</span>()-><span style="font-style:italic">GetI<wbr>nteractor</span>());</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">    </span>image_view->SetColorLevel(<span style="color:#000080">138.<wbr>5</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">    </span>image_view->SetColorWindow(<span style="color:#000080">233</span><wbr>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">    </span>widget.show();</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">    </span>app.exec();</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">    </span>image_view-><span style="font-style:italic">Delete</span>();</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">    </span>reader-><span style="font-style:italic">Delete</span>();</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">    </span><span style="color:#808000">return</span><span style="color:#c0c0c0"> </span><span style="color:#000080">0</span>;</pre>
<pre style="margin-top:0px;margin-bottom:0px">}</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre><div><br></div></div><div><br></div></div><br>______________________________<wbr>_________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_<wbr>FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>