Quote Originally Posted by ultrasonic View Post
I am writing a program which reads lots of data (more than 1000) and show them by drawing a bar chart. I subclassed QWidget , reimplemented paintEvent() to draw my chart and called QScrollArea::setWidget() to setup the chart into the QScrollArea. But when I dragged the scroll bar in the QScrollArea, the scrollbar and chart moved extremely slowly. How do I resolve the problem?
AFAIK QScrollArea repaint its child each times the scrollbars' values change... A solution would be to cache your chart by drawing it into an image/pixmap and displaying this cache. Alternatively you could handle scrolling internally (in your custom widget) without relying on QScrollArea. A third solution could be to reimplement QAbstractScrollArea instead of QWidget, draw your chart and make sure a full repaint isn't done each time the scrollbars move (you might want to take inspiration from QTextEdit source code then...)