0
votes

I am using wxWidgets to draw a large flow chart, i.e. 625 x 26329 pixels. The program was transported from Qt to wxWidgets. It is easy in layout with a main frame which has a customized scroll window inside. The scroll window draws part of the chart every time within updated client region.

Now Qt and wxWidgets make much difference. When scrolling vertically with mouse rolling, Qt refreshs painting the chart very smoothly, while wxWidgets is slowly with flicker.

Can anyone tell me how to make the painting efficiently?

1
Not unless you show some code or at least elaborate on what kind of widgets and/or painting code you are using. One thing that comes to mind is that you might have hardware-accelerated painting enabled via OpenGL on Qt, but not on wxWidgets, though both frameworks support it.teukkam
I do think so, maybe Qt does a lot for me, while wxWidgets must add such supports by hand. BTW how to support hardware acceleration using wxWidgets?allenchen
Secondly, I use wxGCDC to make anti-aliasing effects. Does this need to setup some parameters to gain painting efficience?allenchen
If the Qt implementation uses QPainter for painting the chart, it probably uses an OpenGL backend for painting. Have you looked at this tutorial: wxwidgets.org/docs/tutorials/opengl.htm ?teukkam
Not to mention that Qt uses double buffering in an optimised paint event queue, if wx doesn't it would explain the flickering.cmannett85

1 Answers

1
votes

Are you sure it's slow? I would be wondering, I encounterd a different experience.

You mention flickering. Flickering is mostly result of too many refresh calls. To prevent this you must use double buffering and this is the key.

Double buffering means to draw all stuff offscreen into a image / bitmap and after everything is drawn the image/bitmap is drawn fully (this is done really fast so no flickering :)! ).

Qt uses for default double buffering. That's why it looks everytime smooth. However the downside of this approach is that it consumes performance. wxWidgets doesn't bound you to that. Instead it says, it's your task to get double buffering.

Also you should look whether you aren't clipping the region you're drawing. Clipping under Windows with wxWidgets gave me a really better performance.

PS: Yes, old question but I think it's still needed to know how the facts are.