QT 中 QGLWidget 不能够嵌入到 QGraphicsView 中及解决方案

症状:

QPainter::begin: A paint device can only be painted by one painter at a time.

参考资料:

http://www.qtcentre.org/archive/index.php/t-20669.html

https://bugreports.qt.nokia.com//browse/QTBUG-18813

http://developer.qt.nokia.com/forums/viewthread/5412/

http://doc.trolltech.com/qq/qq26-openglcanvas.html

原因:

QGraphicsScene::addWidget() creates a QGraphicsProxyWidget which does not support widgets which draw directly onto the screen, like a QGLWidget

解决方案:

将QGLWidget设置为QGraphicsView的viewport,然后在QGraphicsView::drawBackground() and QGraphicsView::drawForeground() 中实现渲染

 

posted on 2011-11-13 22:34  大宝pku  阅读(3347)  评论(0编辑  收藏  举报

导航