<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:Consolas;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:1558735319;
mso-list-type:hybrid;
mso-list-template-ids:-1744393674 326418206 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
{mso-level-text:"%1\)";
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:.75in;
text-indent:-.25in;}
@list l0:level2
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:1.25in;
text-indent:-.25in;}
@list l0:level3
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
margin-left:1.75in;
text-indent:-9.0pt;}
@list l0:level4
{mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:2.25in;
text-indent:-.25in;}
@list l0:level5
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:2.75in;
text-indent:-.25in;}
@list l0:level6
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
margin-left:3.25in;
text-indent:-9.0pt;}
@list l0:level7
{mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:3.75in;
text-indent:-.25in;}
@list l0:level8
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:4.25in;
text-indent:-.25in;}
@list l0:level9
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
margin-left:4.75in;
text-indent:-9.0pt;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hi Jon,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> I don’t have time right now, but I can take a look at this later.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> A couple of questions:<o:p></o:p></span></p><p class=MsoListParagraph style='margin-left:.75in;text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><span style='mso-list:Ignore'>1)<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Can you set the vtk widget to the main windows central widget? <o:p></o:p></span></p><p class=MsoListParagraph style='margin-left:.75in;text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><span style='mso-list:Ignore'>2)<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>For the other window, are you using a docking window (QDockWidget) or QDialog?<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Dougie<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> vtkusers-bounces@vtk.org [mailto:vtkusers-bounces@vtk.org] <b>On Behalf Of </b>Jon Agirre<br><b>Sent:</b> Tuesday, January 31, 2012 4:19 AM<br><b>To:</b> vtkusers@vtk.org<br><b>Subject:</b> [vtkusers] qvtkWidget as separate window<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Dear friends,<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>I'm trying to make an application that should be able to summon a separate 3D graphics window from its main window. As for the UI design, I've chosen QT 4 in cooperation with VTK. Despite being familiar with the simpleview qvtkWidget example, I haven't been able to use qvtkwidget in my QT application, at least not the way I'm used to work with QWidgets. Here go the options I've tried:<br clear=all><o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>- qvtkWidget alone as separate window -> crash. While I can create a QWidget object as a separate window, I can't do the same with qvtkwidget.<o:p></o:p></p></div><div><p class=MsoNormal>- qvtkWidget inserted into the layout manager of a separate QWidget, which is created to be a separate window -> crash. If I do not insert it into the layout, the QWidget displays just fine. <o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>The code I use for this later option is as follows:<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><pre><span style='color:silver'> </span><span style='color:maroon'>qvtkWidget</span><span style='color:silver'> </span>=<span style='color:silver'> </span><span style='color:olive'>new</span><span style='color:silver'> </span><span style='color:purple'>QVTKWidget</span>();<o:p></o:p></pre><pre><span style='color:silver'> </span><span style='color:maroon'>window</span><span style='color:silver'> </span>=<span style='color:silver'> </span><span style='color:olive'>new</span><span style='color:silver'> </span><span style='color:purple'>QWidget</span>(<span style='color:olive'>this</span>,<span style='color:silver'> </span><span style='color:purple'>Qt</span>::<span style='color:purple'>Window</span>);<o:p></o:p></pre><pre><span style='color:silver'> </span><span style='color:maroon'>qvtkWidget</span>->resize(<span style='color:navy'>640</span>,<span style='color:navy'>384</span>);<o:p></o:p></pre><pre><span style='color:silver'> </span><span style='color:purple'>vtkSmartPointer</span><<span style='color:purple'>vtkLight</span>><span style='color:silver'> </span>light<span style='color:silver'> </span>=<span style='color:silver'> </span><span style='color:purple'>vtkSmartPointer</span><<span style='color:purple'>vtkLight</span>>::New();<o:p></o:p></pre><pre><span style='color:silver'> </span>light-><i>SetFocalPoint</i>(<span style='color:silver'> </span><span style='color:navy'>0.21406</span><span style='color:silver'> </span>,<span style='color:silver'> </span><span style='color:navy'>1.5</span><span style='color:silver'> </span>,<span style='color:silver'> </span><span style='color:navy'>0</span><span style='color:silver'> </span>);<o:p></o:p></pre><pre><span style='color:silver'> </span>light-><i>SetPosition</i>(<span style='color:silver'> </span><span style='color:navy'>8.3761</span><span style='color:silver'> </span>,<span style='color:silver'> </span><span style='color:navy'>4.94858</span><span style='color:silver'> </span>,<span style='color:silver'> </span><span style='color:navy'>4.12505</span><span style='color:silver'> </span>);<o:p></o:p></pre><pre><span style='color:silver'> </span>VTK_CREATE(<span style='color:purple'>vtkConeSource</span>,<span style='color:silver'> </span>cone);<o:p></o:p></pre><pre><span style='color:silver'> </span>cone->SetHeight(<span style='color:silver'> </span><span style='color:navy'>3.0</span><span style='color:silver'> </span>);<o:p></o:p></pre><pre><span style='color:silver'> </span>cone->SetRadius(<span style='color:silver'> </span><span style='color:navy'>1.0</span><span style='color:silver'> </span>);<o:p></o:p></pre><pre><span style='color:silver'> </span>cone->SetResolution(<span style='color:silver'> </span><span style='color:navy'>50</span><span style='color:silver'> </span>);<o:p></o:p></pre><pre><span style='color:silver'> </span>VTK_CREATE(<span style='color:purple'>vtkPolyDataMapper</span>,<span style='color:silver'> </span>coneMapper);<o:p></o:p></pre><pre><span style='color:silver'> </span>coneMapper->ImmediateModeRenderingOn();<o:p></o:p></pre><pre><span style='color:silver'> </span>coneMapper->SetInputConnection(<span style='color:silver'> </span>cone->GetOutputPort()<span style='color:silver'> </span>);<o:p></o:p></pre><pre><span style='color:silver'> </span><o:p></o:p></pre><pre><span style='color:silver'> </span>VTK_CREATE(<span style='color:purple'>vtkActor</span>,<span style='color:silver'> </span>coneActor);<o:p></o:p></pre><pre><span style='color:silver'> </span>coneActor->SetMapper(coneMapper);<o:p></o:p></pre><pre><span style='color:silver'> </span>VTK_CREATE(<span style='color:purple'>vtkRenderer</span>,<span style='color:silver'> </span>renderer);<o:p></o:p></pre><pre><span style='color:silver'> </span>renderer->SetBackground(<span style='color:navy'>0</span>,<span style='color:silver'> </span><span style='color:navy'>0</span>,<span style='color:silver'> </span><span style='color:navy'>0</span>);<o:p></o:p></pre><pre><span style='color:silver'> </span>renderer->AddLight(light);<o:p></o:p></pre><pre><span style='color:silver'> </span>renderer->AddActor(coneActor);<o:p></o:p></pre><pre><o:p> </o:p></pre><pre><span style='color:silver'> </span><span style='color:maroon'>qvtkWidget</span>-><i>GetRenderWindow</i>()-><i>AddRenderer</i>(renderer);<o:p></o:p></pre><pre><o:p> </o:p></pre><pre><span style='color:silver'> </span><span style='color:maroon'>window</span>->layout()->addWidget(<span style='color:maroon'>qvtkWidget</span>);<o:p></o:p></pre></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>I'm using Mac OS X 10.6, with QT 4 and VTK 5.6.1. The code, as you might guess, mimics the simpleview example. <o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Any clues?<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Thanks for your time,<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Jon<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><p class=MsoNormal>-- <o:p></o:p></p><div><p class=MsoNormal>Dr. Jon Agirre<o:p></o:p></p></div><p class=MsoNormal>Postdoctoral Scientist - Protein and<br>Virus X-ray Crystallography Group<br>Biophysics Unit (CSIC-UPV/EHU)<br>+0034946013357<o:p></o:p></p></div></div></body></html>