[vtkusers] vtk / qt question: qvtkwidget does not resize properly

Clinton Stimpson clinton at elemtech.com
Thu Nov 18 15:01:43 EST 2010


On Thursday, November 18, 2010 06:31:32 am Christian Zemlin wrote:
> Hi vtk-users,
> 
> I would like to use qvtkwidget to render with vtk in a Qt application.
> I started with a standard vtk example:
> 
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Qt/BorderWidget
> 
> which renders a sphere.
> 
> For layout, I created a project in QtCreator, placed a qvtkwidget as the
> only widget in the the form, and applied a vertical (I also tried
> horizontal) layout.
> 
> This compiles and runs, but when I resize the main window, the qvtkwidget
> resized only in the vertical direction (and the sphere grows/shrinks
> accordingly).  In the horizontal direction, the size is fixed, no matter
> how much I enlarge the main window in horizontal direction.
> 
> This problem occurs independently of which "size policy" I use in the Qt
> designer.

You probably mean to ask why the sphere doesn't grow/shrink in the horizontal 
direction when resizing the QVTKWidget?  This is OpenGL related behavior.
Perhaps you want to look at the vtkCamera::HorizontalViewAngle setting to 
adjust that.

Or are you saying the QVTKWidget itself will not grow/shrink in the horizontal 
direction because of something like a size policy being fixed?  If this is your 
problem, then you can ask on a Qt list how to make widgets resize in a 
horizontal direction.

Clint



More information about the vtkusers mailing list