How to call paintEvent
-
I need to display an IplImage (OpenCV structure) I can't use QPixmap because I am updating from another thread which gives me an error that it's unsafe.Now I am using paintEvent
I am using Signals and Slots , Here is the Slot where I receive the image:
@void MainWindow::Show(IplImage *frame)
{
img = QImage(QSize(frame->width,frame->height),QImage::Format_RGB888);
// I need to show img now on ui->frame
// if I use this->update it show a strange image !!}@
Here is the paint event:
@void MainWindow::paintEvent(QPaintEvent *)
{
QPainter painter(this);painter.drawImage(QPoint(ui->frame->x(),ui->frame->y()),img);
}
@but I don't know how to call the paint event.
-
Simply call QWidget::update() from MainWindow Show method and you'll be done !
-
sorry I updated the post , when using this->update It shows me a strange picture not the one caming from the cam, actually it's the same but with strange colors
-
Ok, then try to play with the QImage::format. Are you sure your IplImage is internally stored as 38 bits RGB ? Coulnd't it be a 38 bits BGR image ?
-
Also check the type of RGB values (unsigned, signed, float)