[vtkusers] QVTKWidget is flickering

José M. Rodriguez Bacallao jmrbcu at gmail.com
Mon Jun 4 12:55:34 EDT 2012


hi folks, as I posted previously, I am trying to use QVTKWidget with
QStackedWidget, I have two QStackedWidget nested one inside the other.
For examples, I have a QMainWindow and as central widget is a
QStackWidget that manage what I call "applications". An application is
a simple QWidget, and, in my case, is a QWidget with a QStackWidget
inside it that manage QVTKWidget's (image viewers). The problem arise
when I add a QVTKWidget to the internal QStackedWidget, it show ok
but, has an annoying flickering and I canot allow this in a medical
application, here I post an example code to demostrate what I mean:


from PyQt4 import QtGui, QtCore
import images, vtk


class Workspace(QtGui.QMainWindow):

    def __init__(self, parent=None):
        super(Workspace, self).__init__(parent)

        self.main_tb = self.addToolBar('main')
        self.add_action = self.main_tb.addAction('Add viewer')
        self.add_action.triggered.connect(self.add_viewer)

        self.app_manager = QtGui.QStackedWidget(self)
        self.app_manager.setStyleSheet('background: red;')
        self.setCentralWidget(self.app_manager)

        self.workspace_app = QtGui.QWidget(self.app_manager)
        self.view_manager = QtGui.QStackedWidget(self.workspace_app)
        self.view_manager.setStyleSheet('background: blue;')
        self.workspace_app_layout = QtGui.QHBoxLayout(self.workspace_app)
        self.workspace_app_layout.addWidget(self.view_manager)

        self.app_manager.addWidget(self.workspace_app)
        self.app_manager.setCurrentWidget(self.workspace_app)

    def add_viewer(self):
        viewer = vtk.QVTKWidget(self)
        self.renderer = vtk.vtkRenderer()
        self.renderer.SetBackground(0, 0, 0)
        viewer.GetRenderWindow().AddRenderer(self.renderer)
        self.view_manager.addWidget(viewer)
        self.view_manager.setCurrentWidget(viewer)


if __name__ == '__main__':
    app = QtGui.QApplication([])
    w = Workspace()
    w.showFullScreen()
    app.exec_()

any ideas please, I need to solve this issue as quickly as possible
because of my deadline!!!.



More information about the vtkusers mailing list