PDA

View Full Version : Flicker when sliding QSplitter with QGraphicsView(viewport QGLWidget)



scarecr0w132
1st February 2015, 08:55
Hello,

I am using QGraphicsView with the viewport as QGLWidget.
QGraphicsView and a QTreeView are added to a QSplitter.
Sliding the QSplitter results in flickering on the QGraphicsView.

Adding QGLWidget without QGraphicsView to the QSplitter works as expected.

The following code demonstrates Flickering with QGraphicsView, and no flickering without QGraphicsView when sliding the QSplitter.



#include <QtGui>
#include <QGLWidget>
#include <QtWidgets>

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

// Flickering occurs when sliding a QSplitter with QGraphicsView (viewport QGLWidget).
QGraphicsView *view = new QGraphicsView();
view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
view->setScene(new QGraphicsScene);
QSplitter *graphicsViewSplitter = new QSplitter();
graphicsViewSplitter->addWidget(new QTreeView());
graphicsViewSplitter->addWidget(view);
graphicsViewSplitter->show();

// This works ok with a normal QGLWidget added to a QSplitter.
QSplitter *openGlSplitter = new QSplitter();
openGlSplitter->addWidget(new QTreeView());
openGlSplitter->addWidget(new QGLWidget());
openGlSplitter->show();

return app.exec();
}


Is there a fix for this?

Thanks

scarecr0w132
2nd February 2015, 19:40
Should I report as a bug?

d_stranz
3rd February 2015, 00:41
Your two cases are different, and I doubt the splitter has anything to do with it. Do the same app, except use a single QGraphicsView or QGLWidget as the central widget of a QMainWindow and no splitter. Resize the window and see if you still get flicker.

If so, then it will come down to the differences between what you are displaying. In the first case, you have a graphics view with a scene and a QGLWidget created with a specific QGLFormat as viewport. In the second case, you have only a default constructed QGLWidget. The default QGLFormat format may not be the same as the one you specified int he first case.

It is very, very rare for something so obvious to be a Qt bug. It is almost always a programmer bug instead.

scarecr0w132
3rd February 2015, 10:09
Your two cases are different, and I doubt the splitter has anything to do with it. Do the same app, except use a single QGraphicsView or QGLWidget as the central widget of a QMainWindow and no splitter. Resize the window and see if you still get flicker.

If so, then it will come down to the differences between what you are displaying. In the first case, you have a graphics view with a scene and a QGLWidget created with a specific QGLFormat as viewport. In the second case, you have only a default constructed QGLWidget. The default QGLFormat format may not be the same as the one you specified int he first case.

It is very, very rare for something so obvious to be a Qt bug. It is almost always a programmer bug instead.

Hello d_stranz,

QGraphicsView with QGLWidget viewport in normal window is fine.
QGraphicsView with QGLWidget viewport added to QSplitter has weird behavior when sliding the QSplitter (and resizing the window).
QGLWidget added to QSplitter is fine.
QGraphicsView (without QGLWidget viewport) added to QSplitter is fine.



QGraphicsView *view = new QGraphicsView();
view->setViewport(new QGLWidget());
view->setScene(new QGraphicsScene());
QSplitter *graphicsViewSplitter = new QSplitter();
graphicsViewSplitter ->addWidget(new QTreeView());
graphicsViewSplitter->addWidget(view);
graphicsViewSplitter->show();


Thanks

Added after 26 minutes:

It was a bug that has been fixed in 5.4
https://bugreports.qt.io/browse/QTBUG-38327

d_stranz
3rd February 2015, 17:19
It was a bug that has been fixed in 5.4

Hah! Well, I will go and eat my humble pie now.