[PyQt] QGLWidget c++ widget works, SIP binding doesn't

Josh Knox jknox at irobot.com
Tue Apr 20 20:56:16 BST 2010

Hi All,

I've got a simple custom QGLWidget that works fine when loaded from c++. 
(basically the Sierpinski demo)

I've built a SIP binding against it, that I can load from python but it 
only ever displays a black area and it appears that the event loop never 

My SIP file is trivial:

    %Import QtCore/QtCoremod.sip
    %Import QtGui/QtGuimod.sip

    %Import QtOpenGL/QtOpenGLmod.sip
    %Module MyGLTest 0

    class MyGLWidget : QGLWidget
    #include "../MyGLTest/include/QtGLTest.hpp"
    #include <QGLWidget>

        MyGLWidget(QWidget* parent /TransferThis/ = 0, const QGLWidget*
    shareWidget = 0, Qt::WindowFlags f = 0);


My Python script to show it is also trivial (essentially equivalent to 
the C++ code to do the same):

    import sys
    from PyQt4 import QtGui
    from MyGLTest import MyGLWidget

    if __name__ == "__main__":

        app = QtGui.QApplication(sys.argv)

        # test the simple GL widget
        myGLWidget = MyGLWidget()
        myGLWidget.resize(400, 350)


This just launches a Qt window with an all black widget area.

So, given that the C++ widget works, what could I be missing that's 
prevent the SIP binding from running properly?

I'm still new at this, so any ideas appreciated!



More information about the PyQt mailing list