Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSplitter/QGLWidget combination flicker on OSX
Forum Update on Monday, May 27th 2025

QSplitter/QGLWidget combination flicker on OSX

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    r2d3
    wrote on last edited by
    #1

    Hi,

    I am using Qt 4.7.1 on OSX 10.6 and I am having trouble with redraw flicker when putting QGLWidget in a QSplitter.

    The following code shows how to reproduce the problem.

    When moving the first handle, the background (splitter/mainwindow) redraws in gray/white before the QGLWidget redraws in black.

    I have added a second splitter inside the first splitter to show of this redraw latency adds up when moving the second handle.

    If someone already encountered this problem and have a solution/workaround. I found nothing related on http://bugreports.qt.nokia.com

    Thanks for your time.

    David

    main.cpp
    @
    // This example demonstrates a flickering problem that arise
    // when combining QGLWidget and QSplitter on OSX

    #include <QApplication>
    #include <QGLWidget>
    #include <QMainWindow>
    #include <QSplitter>

    // Uncomment this to see that QWidget does not have the same "flicker" problem as QGLWidget
    //#define USE_QWIDGET

    // This exhibit the problem when the latency of redraw is adding up
    #define USE_SUBSPLITTER

    class GLWidget : public QGLWidget
    {
    Q_OBJECT
    public:
    GLWidget(QWidget *parent = 0, const QGLWidget *shareWidget = 0, Qt::WindowFlags f = 0)
    : QGLWidget(parent, shareWidget, f)
    {
    setAttribute(Qt::WA_OpaquePaintEvent);
    setAutoFillBackground(false);
    }

    protected:
    virtual void initializeGL() { qglClearColor(Qt::black); }
    virtual void paintGL() { glClear(GL_COLOR_BUFFER_BIT); }
    virtual QSize sizeHint() const { return QSize(800,600); }
    };

    class MainWindow : public QMainWindow
    {
    Q_OBJECT
    public:
    MainWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0) : QMainWindow(parent, flags)
    {
    setObjectName("MainWindow");
    setAttribute(Qt::WA_OpaquePaintEvent);
    setAutoFillBackground(false);

        QSplitter *splitter = new QSplitter(this);
    

    #ifndef USE_QWIDGET
    splitter->setAttribute(Qt::WA_OpaquePaintEvent);
    setAutoFillBackground(false);
    #endif

        addWidgetToSplitter(splitter);
        addWidgetToSplitter(splitter);
    

    #ifdef USE_SUBSPLITTER
    QSplitter *splitter2 = new QSplitter(this);
    addWidgetToSplitter(splitter2);
    addWidgetToSplitter(splitter2);
    splitter->addWidget(splitter2);
    #endif

        setCentralWidget(splitter);
    }
    

    private:
    void addWidgetToSplitter(QSplitter *splitter)
    {
    #ifndef USE_QWIDGET
    splitter->addWidget(new GLWidget(splitter));
    #else
    QWidget *widget = new QWidget(splitter);
    widget->setBackgroundRole(QPalette::ButtonText);
    widget->setAutoFillBackground(true);
    splitter->addWidget(widget);
    #endif
    }
    };

    int main(int argc, char **argv)
    {
    QApplication app(argc, argv);

    MainWindow window;
    window.showMaximized();
    
    return app.exec&#40;&#41;;
    

    }

    #include "main.moc"
    @

    splitter.pro
    @
    TEMPLATE = app
    TARGET =
    DEPENDPATH += .
    INCLUDEPATH += .
    QT += opengl
    SOURCES += main.cpp@

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved