[Qt-interest] custom OpenGL widget update blocks other Qt GUI rendering

Christopher Lux christopherlux at gmail.com
Tue Oct 5 13:50:52 CEST 2010


Hi,
could some Qt internal comment on the issue of constantly updating a
GL context without breaking the rest of the GUI?

Regards
-chris

On Mon, Oct 4, 2010 at 2:00 PM, Christopher Lux
<christopherlux at gmail.com> wrote:
> Hi,
> i have a custom OpenGL widget which basically looks like the code
> snippet on the bottom of the mail.
>
> I use this->update() to force a redraw. If i understand the
> documentation correctly update() just inserts a update event in the
> event queue, so all other events of the application should not be
> influenced. For example when i open a modal QFileDialog, the update
> should be postponed until the dialog returns. But since Qt 4.6.x i can
> see the OpenGL content being updated even of the QFileDialog is open
> and the rest of the GUI becomes really unresponsive (under Windows,
> under X11 the QFileDialog does not even render correctly).
>
> I do not want to transfer the OpenGL rendering into another thread. Is
> there any way to get the old blocking behavior back?
>
> Regards
> -chris
>
> class viewer_widget : public QWidget
> {
>    Q_OBJECT
>
> public:
>    viewer_widget(QWidget* parent = 0, [custom context initializer])
>  : QWidget(parent, Qt::MSWindowsOwnDC)
>    {
>    setMouseTracking(true);
>    setFocusPolicy(Qt::StrongFocus);
>
>    setAttribute(Qt::WA_NativeWindow, true);
>    setAttribute(Qt::WA_PaintOnScreen, true); // disables qt double
> buffering (seems X11 only since qt4.5, ...)
>    setAttribute(Qt::WA_NoSystemBackground, true);
>    setAutoFillBackground(false);
>
>    [initialization of my own context etc]
>
>    }
>    virtual ~viewer_widget();
>
>    QPaintEngine*               paintEngine() const { return 0; }
>
> protected:
>    void                        paintEvent(QPaintEvent* paint_event)
>    {
>        paint_event->accept();
>
>        [render the scene etc.]
>
>        this->update();
>    }
>    void                        resizeEvent(QResizeEvent* resize_event)
>    {
>        [update size etc.]
>    }
>




More information about the Qt-interest-old mailing list