Asynchronous drawing problems
General and Desktop
3
Posts
3
Posters
2.9k
Views
1
Watching
-
I have one thread that reads image data from an external API. This image data I want to draw in an Qt application. I have created a widget to draw the image. The thread calls MyWidget::setPicture. However I get lots of strange X server errors, so I'm guessing something is not threads safe. Any tips on how to do this?
@
class MyWidget : public QWidget
{
Q_OBJECT
public:
MyWidget(QWidget *parent = 0);
~MyWidget();QPixmap pixmap; void setPicture(QImage);protected:
void paintEvent(QPaintEvent *event);};
@@
void MyWidget::paintEvent(QPaintEvent */event/) {
QPainter painter(this);
painter.drawPixmap(this->rect(),pixmap);
}void MyWidget::setPicture(QImage i){
pixmap=QPixmap::fromImage(i);
update();
qApp->processEvents();
}@