[SOLVED] OpenGL lists does not work in custom QGraphicsItem's paint() with plain QGLWidget

  • The documentation says that you can use OpenGL commands anywhere until you do a makeCurrent() for the QGLWidget. I still cannot make an OpenGL list show anything from a custom QGraphicsItem's paint() function. The OpenGL m_List of GL_POINTS is created in the constructor, and the paint function is the following:

    @void Points::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget * widget)
    if (painter->paintEngine()->type() != QPaintEngine::OpenGL &&
    painter->paintEngine()->type() != QPaintEngine::OpenGL2 )
    { return; }

    QGLWidget* glwidget = dynamic_cast<QGLWidget*>(widget);
    // glwidget->renderText(2000,3000,10,"whatever"); // does not work either

        glCallList(m_List); // does not work


    The widget does not show anything. Doing plain painter->draw...() functions do work.

    Other examples where OpenGL commands issued in a customized QGLWidget do work correctly. Can anybody point me an example where plain OpenGL is used outside that class for displaying in a QGLWidget?

    EDIT: found the answer. 4.6 introduced the QPainter::beginNativePainting() and QPainter::endNativePainting() functions. With those it works fine. More about the topic:


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.