[vtkusers] Using QVTKWidget

Joey Mukherjee joey at swri.edu
Wed Apr 27 16:19:37 EDT 2005


On Apr 27, 2005, at 11:43 AM, Clinton Stimpson wrote:

>> I usually use Motif as my GUI of choice, but I wanted to try Qt and 
>> the new QVTKWidget.  However, the interface seems to be very 
>> different than the Motif one.
>>
>> For instance, in Motif, I create a
>>
>>  _iren = vtkXRenderWindowInteractor::New ();
>>
>> and then do a:
>>
>>         extern XtAppContext application_context;
>>         ((vtkXRenderWindowInteractor *) _iren)->Initialize 
>> (application_context);
>>         _iren->Enable ();
>>
>> and a new Window is drawn and I can interact with it.
>>
>> On Qt, this interface does not seem to work.
> No it doesn't work.  Don't use vtkXRenderWindowInteractor at all if 
> you are going to use QVTKWidget.
>> What is unique (maybe) about what I do is I let VTK create the window 
>> for me.
> It is fine to go as far as creating an instance of a vtkRenderWindow, 
> but that window should be given to a QVTKWidget before it is 
> initialized.

I really explained this wrong - sorry.  I am marginally new to Qt, but 
am familiar enough with it.  I have a full Qt app.  I was just showing 
what I did in Motif compared to how I was expecting (hoping!) the Qt to 
work.

Here's what I have:

#ifdef _QT_
     _renWin = vtkRenderWindow::New ();
     _qvtk = new QVTKWidget ();
     _qvtk->SetRenderWindow (_renWin);
#else

When I would normally (i.e. in a Motif program) do an "iren->Enable", I 
have :

#ifdef _QT_
//        extern QApplication *qApp;
//        ((QVTKInteractor *)_iren)->Enable ();
         _qvtk->show ();
//        qApp->setMainWidget (_qvtk);
//        qApp->exec ();
#endif


> So it appears you just want a top level window in a Qt GUI.  In that 
> case, just create a QVTKWidget without a parent, and be sure to call 
> show() on it.  The ImageViewer example is the closest to this 
> scenario.

As you can see, I do exactly that.  However, the window now pops up, 
but there is nothing in it.  It is like the window is not receiving any 
events since I can resize the window and the window seems to take on 
the "image" of the windows behind it or my background.  This is on 
Solaris 9.  I wonder if this is some sort of GL problem...

Any ideas?

Joey

P.S.  Wagner - thanks for those examples!  I'll check them out of CVS.




More information about the vtkusers mailing list