I'm writing an app where the widget has a QImage that is filled by
calls on another thread. I then want the image to update on the
screen. The problem, of course, is the update can't be called from
another thread. I'm somewhat familiar with this problem using Qt in
C++ and python, but not sure how to setup my signals in QtJambi.
Could someone give me some advice? Also, should I do a mutex lock
around the code in imageUpdate if several threads are called it?
class RenderWidget(parent:QWidget) extends QWidget(parent) with Display {
var colorBuffer = null : QImage
var bufferPainter = null : QPainter
def imageBegin(width:Int,height:Int,bucketSize:Int) {
colorBuffer = new QImage(width,height, QImage.Format.Format_RGB32)
bufferPainter = new QPainter(colorBuffer)
}
def imageEnd() {
}
def imageFill(x:Int,y:Int,w:Int,h:Int,color:Color) {
}
def imagePrepare(x:Int,y:Int,w:Int,h:Int,id:Int) {
}
def imageUpdate(x:Int,y:Int,w:Int,h:Int,data:Array[Color]) {
// this will eventually be replaced by code to fill in the
specified block
bufferPainter.setBrush(new QBrush(new QColor(50,50,50)))
bufferPainter.drawEllipse(x,y,100,100)
update() // this is the problem
}
override def paintEvent(event:QPaintEvent) {
val painter = new QPainter(this)
painter.drawImage(50,50,colorBuffer)
}
}
_______________________________________________
Qt-jambi-interest mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest