[PyQt] VTK in PyQt
Gib Bogle
g.bogle at auckland.ac.nz
Wed Mar 10 09:00:34 GMT 2010
Hi Matt and Bastian,
Thanks for your responses. I am now setting the size of the scene:
VTKscene = QVTKRenderWindowInteractor(self)
VTKscene.Initialize()
VTKscene.Start()
VTKscene.setGeometry(QtCore.QRect(200, 200, 600, 600))
renWin = VTKscene.GetRenderWindow()
This all works nicely, and I display a cone in the scene that I can rotate.
I also create a widget and a QVBoxLayout that I hope to use as the screen to
display VTKscene:
page_VTK = QtGui.QWidget(self)
layout = QtGui.QVBoxLayout(page_VTK)
I can add a couple of widgets to layout (e.g. a QGroupBox, a QSlider), and then
add page_VTK to the list of stacked widgets. All this behaves as expected, and
I can switch between my screens, one of which is page_VTK. But whatever I do I
can't attach VTKscene to page_VTK. If I try:
layout.addWidget(VTKscene)
it just disappears. Without this line I see VTKscene, on top of whatever screen
I'm displaying. So the crucial missing step is embedding VTKscene within layout
(or page_VTK). The missing step is probably very simple, but my understanding
of how Qt works is not adequate to identify it.
Cheers
Gib
Matt Smith wrote:
> I looked through the code and two things I see different than what I
> have:
>
> a. I set the size of my RenderWindow
> b. I keep a reference to it, which probably isn't your problem because
> your not getting a seg fault.
>
> I've got an example but I can't verify that it works since I don't have
> vtk installed atm.
>
> mbs
>
More information about the PyQt
mailing list