Contert int matrix to QPixmap

hello everyone:
First of all thanks a lot for reading this post and being able to help:
I have a matrix like:
int **matrix;
with specific size.
I would like to transform this matrix (a element is a pixel of the image) to a QPixmap to visualize the image in a scene.
how can I do thatÂ¿?
PD: From QImage to int** matrix the code looks like:
matrix = new int *[img.width()]; for(int i=0;i<img.width();++i) matrix[i] = new int [img.height()]; for(int i=0;i<img.width();++i){ for(int j=0;j<img.height();++j) matrix[i][j] = QColor(img.pixel(i,j)).black() > 127 ? 0:1; }
So the invert way to QPixmap?
Thanks a lot.

Hi! The way to convert your matrix to a QPixmap is to convert it to QImage first (e.g. using
void QImage::setPixel(const QPoint &position, uint index_or_rgb)
) and then convert the QImage to a QPixmap (using[static] QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags = Qt::AutoColor)
).