[Qt-interest] custom widgets and OpenGL

Oliver.Knoll at comit.ch Oliver.Knoll at comit.ch
Fri Nov 12 11:45:52 CET 2010


On 2010-11-12 ITS-CMT-SUI-SL-SFR-FIN-DEV Knoll Oliver, ITS-CMT-SUI-SL-SFR-FIN-DEV wrote:

> ...
> Uhm... and just now I found this article which pretty much shows what you want, I
> guess. Apparently you CAN use "raw OpenGL commands" inside a
> QGraphicsView! Here is how:
> 
>   http://doc.trolltech.com/qq/qq26-openglcanvas.html

By the way, the provided example qq26-openglcanvas.zip did not run on my Windows XP with Qt 4.7.0. It turned out that the "PaintEngine" is of type QPaintEngine::OpenGL2 and not just QPaintEngine::OpenGL

So I daringly extended the test like this:

void OpenGLScene::drawBackground(QPainter *painter, const QRectF &)
{
  if (painter->paintEngine()->type() != QPaintEngine::OpenGL && painter->paintEngine()->type() != QPaintEngine::OpenGL2) {
    ...
  }
  ...
}

Like this the example ran perfectly.

Maybe a method QPaintEngine::isOpenGL() would be helpful here as well :)

Cheers, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22






More information about the Qt-interest-old mailing list