Hi all
I am writing a python application with PyQT for MAEMO 5 (N900).
I have to draw a graph with a lot of lines (see http://maemo.org/downloads/product/M...sleepanalyser/)
It works fine, how ever now I want to put the draw into a scroll area.
It works, however it is very slow when I scroll the area, as it is redrawing it all the time.
Is there a way I can store the drawing into a pixmap so it takes it from there?
It is a static drawing and does actually only have to be drawn once when I load the widget.
I searched the web all over but could not find a solution, mayby I search at the wrong corner.
A working example:
def paintEvent(self, event):
paint.begin(self)
paint.
setPen(QtGui.
QColor("white")) paint.
setBrush(QtGui.
QColor("black"))
paint.drawRect(0,0,800,50)
paint.
setPen(QtGui.
QColor("yellow")) for i in range(0, 800):
l=int(random.uniform(0,30))
paint.drawLine(i, 48, i, l)
paint.end()
def paintEvent(self, event):
paint = QtGui.QPainter()
paint.begin(self)
paint.setPen(QtGui.QColor("white"))
paint.setBrush(QtGui.QColor("black"))
paint.drawRect(0,0,800,50)
paint.setPen(QtGui.QColor("yellow"))
for i in range(0, 800):
l=int(random.uniform(0,30))
paint.drawLine(i, 48, i, l)
paint.end()
To copy to clipboard, switch view to plain text mode
I guess I have to use something like QImage or QBitmap, but I dont know how.
All I want is to draw it once and buffer it somewhere, so it can be taken from there every time paintEvent gets called.
Thank you for your advice!
Bookmarks