You can create a Mat image directly from QByteArray without the need of creating a QImage

Mat img = Mat(WIDTH,HEIGHT, CV_8UC1, imagesData.data());

Regards