[vtkusers] Integrate a vtk view in a QGraphicsScene using the QVTKGraphicsItem on windows.
rdebroiz
rene-paul.debroize at irisa.fr
Thu Apr 17 08:08:34 EDT 2014
Hello,
I'm currently trying to integrate a vtk view in a QGraphicsScene using
the QVTKGraphicsItem. When it works perfectly under linux or mac, I
encounter some difficulties on windows. Note that I used VTK 5.10 and
Qt4.8.5, and also tested the master of the VTK git repository .
My problem is first that I can not execute the example 'qtgraphicsView'
from VTK, I get a crash at line 115 of QVTKGraphicsItem.cxx:
/void QVTKGraphicsItem::MakeCurrent()//
//{//
//mContext->makeCurrent();/
This seems to be due to the fact that under windows, calling
QGraphicsView::setViewport(QWidget *w) with w being a QGLWidget,
invalidates the current QGLContext if any, and then end up on a crash if
one tries to call create or makeCurrent on it.
A simple workaround to this behavior can be to change the three first
line of the constructor of GraphicsView in GraphicsView.hpp from the
example, in order to get the QGLContext after calling the setViewport
method :
/class GraphicsView : public QGraphicsView//
//{//
// public://
// GraphicsView()//
// {//
//// mCtx = new QGLContext(QGLFormat());//
//// mWidget = new QVTKWidget2(mCtx);//
//// this->setViewport(mWidget);//
//
// mWidget = new QVTKWidget2;//
// this->setViewport(mWidget);//
// mCtx = const_cast<QGLContext*>(mWidget->context());/
This works like a charm with linux (no significant changes with the
original) and fixes the crash with windows but results in terrible
performance, (try to interact wit the treeRingItem for example.)
My questions are, is there anybody on this mailing list having the same
issues, Does it comes from a bad configuration, or is it a VTK problem ?
If it is a VTK problem does someone have any idea on how to solve it ?
Thanks !
rdebroiz.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140417/869b35d6/attachment.html>
More information about the vtkusers
mailing list