[vtkusers] QVTKWidget2 window flickered

septem septem.wu at gmail.com
Tue Aug 28 21:29:40 EDT 2012


Thank you for your reply.

I have read the topic, but my QVTKWidget2 already has a parent widget, so
when I call QStackedWidget's method SetCurrentWidget(), QVTKWidget2's parent
will not be changed.

Here's my Code:

class View : public QWidget
{
public:
	View(QWidget* parent = 0):QWidget(parent)
	{
		QVTKWidget2* myVtkWnd = new QVTKWidget2();
		QToolBar* myTB = new QToolBar();
		
		//... initial renderer and set background color
		
		QVBoxLayout* vLayout = new QVBoxLayout();
		vLayout->addWidget(myTB);
		vLayout->addWidget(myVtkWnd);
		
		setLayout(vLayout);
	}
	~View() {}
};

class WorkSpace : public QWidget
{
public:
	WorkSpace(int rowCount, int colCount, QWidget* parent = 0):QWidget(parent)
	{
		QGridLayout* gLayout = new QGridLayout();
		for(int r=0; r<rowCount; ++r)
		{
			for(int c=0; c&lt;colCount; ++c)
			{
				gLayout->addWidget(new View(),r,c);
			}
		}
		
		setLayout(gLayout);
	}
	~WorkSpace() {}
};

class MainWindow : public QMainWindow
{
public:
	MainWindow(QWidget* parent = 0):QMainWindow(parent)
	{
		QStackedWidget* myStack = new QStackedWidget();
		myStack->addWidget(new WorkSpace(1,3));
		myStack->addWidget(new WorkSpace(2,2));
		myStack->addWidget(new WorkSpace(1,1));
		
		setCenterWidget(myStack);
	}
	~MainWindow() {}
	
	void SwitchTo(int index)
	{
		myStack->setCurrentIndex(index);
	}
};

int main(int argc,char* argv[])
{
	QApplication app(argc,argv);
	MainWindow wnd;
	wnd.show();
	
	return app.exec();
}

When I call SwitchTo(int) method to change WorkSpace Layout, the QVTKWidget2
is flickering..

Thank you



--
View this message in context: http://vtk.1045678.n5.nabble.com/QVTKWidget2-window-flickered-tp5715588p5715618.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list