You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Monday, February 13th 2012, 2:23pm

Limiting repaint events somehow

I have an app.
Multiple tabs.. quite a large number of widgets on each. labels/buttons ect.
Most of these labels is getting updated information multiple times per second.

On ons of these tabs I have a potentially opengl qGraphicsView scene.
Which is quite intensive on the cpu/hardware.

What I found out is that if any single widget redraws it seems the whole gui redraws itself.
This includes widgets on other tabs.

The result is a rather ineffecient application that basicly makes the cpu die.
This is mostly problematic with the opengl widget when its in non-gl/software mode.

I could find no way to force it down to a fix frame rate.

I tried everything I can find or think of all ready.


setViewportUpdateMode(QGraphicsView::NoViewportUpdate); - no effect


I played with: setUpdatesEnabled(false);
but mostly the result is times when the widget is not drawn.


If I click on a button next to the widget then somehow the paint event transfers over to all other widgets.
Its as if when a widget redraws is forces its parent to redraw which then in turn forces all its children to redraw and this then runs recursively through the complete application :(

Please is there anyway to make Qt behave itself?

I should perhaps mention that:
1. I don't use fixed sized widgets - I use Qts layouts to position things mostly.
2. I have a rather large style sheet loaded over everything.

What really freaks me is that stupid Qt will redraw the non-visible tabs.. this is fail.

2

Monday, February 13th 2012, 3:00pm

get rid of the stylesheet and see what happens.

also make sure you have built a release build and removed debugging checks/asserts etc. - there is no point complaining about performance in a debug build ;)
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

3

Monday, February 13th 2012, 3:26pm

oh yea, I just did a quick test - tab widget does not draw hidden tabs (qt 4.7.0 win7 x64)
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

4

Tuesday, February 14th 2012, 7:56am

style problems :(

hi

THANKS ALOT FOR YOUR RESPONSE!!

I compiled for release.. this helped a little bit.. at least the file size is smaller.
I noticed that the amount of redraws between opengl mode and software mode differ slightly but thats ok.

However I noticed that the stylesheet is the problem.
If the stylesheet is on the QGraphicsView seems to redraw consistantly as other widgets on the screen around it updates.
When I removed the stylesheet this behaviour ends.

I've attached my stylesheet.. I'm not an expert in stylesheets.. so please point out what I screwed up :)

Here is my code that loads the stylesheet:
void MainWindow::loadStyle(QString filename)

{

QFile sfile(filename);

if (sfile.open(QIODevice::ReadOnly | QIODevice::Text))

{

QTextStream in(&sfile);

QString styleString = in.readAll();

if (!styleString.isEmpty())

{

this->setStyleSheet(styleString);

}

else

{

qCritical() << "Style file is empty!";

}

}

else

{

qCritical() << "Failed to open Style file: " << filename;

}

}


This function is the last thing called in main window constructor after all gui widgets and other things have been setup.

Marcaunon has attached the following file:
  • darkStyle1.txt (5.55 kB - 1 times downloaded - latest: Feb 14th 2012, 8:20am)

5

Tuesday, February 14th 2012, 8:20am

I don't know much about stylesheets either I'm afraid.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.