Qt 4.7.1 and QImage::convertToFormat
-
Hello,
I'm quite new to Qt so please bear with me.
My application uses Qt and stylesheets which causes a huge lag when switching between tabs.
When removing the stylesheets everything seems to work fine.
The thing is that I profilled the application and noticed that alot of the time is spent in QImage::convertToFormat.
My guess is that this has to do with the fact that the styled GUI has lots of images, but still why does Qt has to call it each time?
Also the function is not explicitly called by the application.
So am I doing something wrong or is this normal behaviour?Thanks.
-
I would imagine repeating calls to QImage::convertToFormat would be expensive, yes. It is weird that Qt would try converting the same images over and over again. That should happen only once, when needed, and the result should be cached.
Would it be feasible for you to try to see what format your images are converted to, and see if you can adapt the format of your actual images to conform to that format? That might speed up your application then.
In the meantime, I would file a "bug":http://bugreports.qt.nokia.com outlining the issue.
-
AFAIK I can't see what format the images are converted to.
Also I checked and when resizing the application this happens also
which probably means that Qt is calling convertToFormat each time it has
to repaint the widget.
Any more help would be much appreciated. -
You might be able to find out the format by setting a breakpoint in that method in QImage. That would allow you to inspect the format that was requested.
-
Thanks, will do.
Be back pronto. -
[quote author="CableGuy" date="1301562315"]Hello,
My application uses Qt and stylesheets which causes a huge lag when switching between tabs.
When removing the stylesheets everything seems to work fine.
The thing is that I profilled the application and noticed that alot of the time is spent in QImage::convertToFormat.
My guess is that this has to do with the fact that the styled GUI has lots of images, but still why does Qt has to call it each time?
Also the function is not explicitly called by the application.
So am I doing something wrong or is this normal behaviour?Thanks.[/quote]
How did you build up your style sheet?
What we found is that having huge style sheets (ours is about 4k lines) using together with many widgets (the test has about > 1000 widgets) gets slow during creation time. Runtime is ok.So here are my questions:
do you (re)create the tabs while switching?
Do you use huge style sheets on application level? Or only per widget?
do you use stuff like border / background images in the style sheet?
-
I can't seem to get my debugger to show the Qt source...
I'll try creating a small test app and see what happens there. -
- I'm not sure, I do hope not, but as mentioned this happens also when just resizing the window
- I have quite a big stylesheet ~4.5K lines in it used in application level.
- I don't know much about stylesheets but yes, there background images, border images.
I don't think the stylesheet itself is the cause but rather all the images/background images...
-
[quote author="CableGuy" date="1301569935"]I can't seem to get my debugger to show the Qt source...
I'll try creating a small test app and see what happens there.[/quote]Are you linking against a debug version of Qt?
-
Using images in the style sheet could lead to new calculations on resizing, as the images need to be streched etc. This could be an issue. Especially as you said, without style sheet, you don't have those problems.
-
For what it's worth, further inverstigation showed that the execessive amount of QImage::convertToFormat calls
were caused by the usage of linear gradients and not images and after more googling, luanching the application
with -graphicssystem raster turned out to be a huge speed improvement. The question that still remains is why using the raster graphics system (which AFAIK is pure software) is faster that the usage of native X11?