PDA

View Full Version : [QGLWidget/QGLView][QSplitter] slow performance?



faizol
22nd October 2012, 15:33
Hi all,

What should I do to speed up the resizing performance?


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

class GLWidget : public QGLWidget
{
public:
GLWidget(QWidget *parent = 0) : QGLWidget(parent) {}
GLWidget(const QGLFormat &format, QWidget *parent = 0, const QGLWidget *shareWidget = 0, Qt::WindowFlags f = 0) :
QGLWidget(format, parent, shareWidget, f){}

protected:
virtual void paintGL();
virtual void resizeGL(int, int) { }
};

void GLWidget :: paintGL()
{

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

glTranslatef(0.5f,0.5f,0.0f);

glBegin(GL_QUADS);
glVertex3f(-1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glEnd();
}

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

QMainWindow mainwindow;

mainwindow.setFixedSize(1000,600);

QSplitter *splitter = new QSplitter(Qt::Horizontal);
splitter->addWidget(new QTextEdit());
splitter->addWidget(new GLWidget());

mainwindow.setCentralWidget(splitter);

mainwindow.show();

return app.exec();
}


Thanks in advance.

Cheers,
Faizol

wysota
22nd October 2012, 16:11
Please define "speed up".

faizol
22nd October 2012, 16:43
Please define "speed up".
An increase in speed performance relative to the current speed regardless of what is the base speed?

Added after 4 minutes:

is this a still open bug as reported here?
https://bugreports.qt-project.org/browse/QTBUG-17869

Thanks.

wysota
22nd October 2012, 17:07
An increase in speed performance relative to the current speed regardless of what is the base speed?
Oh... such a smart definition. Ok, here you go -- to get a speed up, use an empty window instead of one with content!

/me is astonished by his brilliant answer...

faizol
22nd October 2012, 17:12
Oh... such a smart definition. Ok, here you go -- to get a speed up, use an empty window instead of one with content!

/me is astonished by his brilliant answer...

LOL.

On the other hand, you can just let other users who are willing to help to answer it. Surely I appreciate any help and I'll try to help other users as well.

wysota
22nd October 2012, 17:47
On the other hand, you can just let other users who are willing to help to answer it.
I am trying to help but if you ask a general question, you can only get a general answer.

BTW. I can see your original post content...

faizol
22nd October 2012, 18:30
I am trying to help but if you ask a general question, you can only get a general answer.
I can't be more specific as the question -is- general (the same with the sample given). Otherwise the sample would have been more specific.


BTW. I can see your original post content...
you should, as that was for you (the golden rule in action). But out of respect to other users, I decided to edit it.

wysota
22nd October 2012, 20:45
I can't be more specific as the question -is- general (the same with the sample given). Otherwise the sample would have been more specific.
Then the proper answer for such a general question is "do less" and that's what you were given. I'm not sure what other answer you expected to get.

Actually I can be a bit more specific but I don't think it will do you any good... You can manipulate the "opaqueResizing" property of QSplitter. Other than that, with such a short snippet as what you provided there is nothing you can do with your code to get a spectacular speed improvement. You can fix Qt if you're suffering from some bug in QSplitter code...

faizol
22nd October 2012, 21:31
Thanks. I've done some simple testing based on your answer and that got me to a point where I can do a bit more experimentations with my code. Really appreciate it.

Cheers,
Faizol

faizol
23rd October 2012, 18:54
Tested the attached code with Qt5 beta and the lagging response was when linking with Qt5. On the contrary the interactivity was ok when the code was linked against Qt4. Didn't quite expect the gap in performance.

Cheers,

faizol
29th October 2012, 11:17
status: reported, and accepted as a critical bug (Qt5).

faizol
15th November 2012, 00:04
Status: regression resolved

https://codereview.qt-project.org/#change,39437

Change By: Samuel Rødal (14/Nov/12 3:21 PM)
Status: Resolved
Changes: 4334e0fcc60497da73671063deb68fb1661f864c
Fix Version/s: 5.0.0 RC 1
Resolution: Done

wysota
15th November 2012, 05:36
Congratulations :)

faizol
15th November 2012, 08:49
Congratulations :)

That belongs to Samuel Rødal who did all the work and credits are all his.

Glad though this is resolved and I can go back and start coding using Qt5 again.

Many thanks.

Cheers,
Faizol