[vtkusers] QVTKWidget trying to put a cone and a qpushbutton, together

Clinton Stimpson clinton at elemtech.com
Wed Jul 12 01:07:32 EDT 2006


I took another quick look at this...  it can be solved by doing

vtkRenderWindow *renWin = vtkRenderWindow::New();
widget.SetRenderWindow( renWin );

before you call 

QPushButton *button = new QPushButton( "hola", &widget );

Instead of after. 

Clint


> I am trying to put together a cone and a gui elements such a QPushButton, 
> this is the code...
>
> #include<QApplication>
> #include<QPushButton>
>
> #include"vtkConeSource.h"
> #include"vtkPolyDataMapper.h"
> #include"vtkActor.h"
> #include"vtkRenderer.h"
> #include"vtkRenderWindow.h"
>
> #include "QVTKWidget.h"
>
> int main(int argc, char** argv)
> {
>   QApplication app(argc, argv);
>
>   QVTKWidget widget;
>   widget.resize(256,256);
>
> #if QT_VERSION < 0x040000
>   app.setMainWidget(&widget);
> #endif
>
> QPushButton *button = new QPushButton( "hola", &widget );
>
>
> vtkConeSource *cone = vtkConeSource::New();
> cone->SetHeight( 3.0 );
> cone->SetRadius( 1.0 );
> cone->SetResolution( 20 );
>
> vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New();
> coneMapper->SetInputConnection( cone->GetOutputPort() );
>
> vtkActor *coneActor = vtkActor::New();
> coneActor->SetMapper( coneMapper );
>
> vtkRenderer *ren = vtkRenderer::New();
> ren->AddActor( coneActor );
> ren->SetBackground( 0.1, 0.2, 0.4 );
>
> vtkRenderWindow *renWin = vtkRenderWindow::New();
> renWin->AddRenderer( ren );
>
>   widget.SetRenderWindow( renWin );
>
>   widget.show();
>
>   app.exec();
>
>   cone->Delete();
>   coneMapper->Delete();
>   coneActor->Delete();
>   ren->Delete();
>   renWin->Delete();
>
>   return 0;
> }
>   




More information about the vtkusers mailing list