If the image is a bitmap, use the QBitmap::fromData
function to create the QPixmap
. It is documented here.
Or use QPixmap::loadFromData
to allow Qt to attempt to detect the data format based on information in the image header.
Question
I'm currently integrating DigitalPersona U.are.U into a Qt Application. I've been able to obtain image DATA_BLOB from the DPFPApi. The only problem I have now is to preview the image by setting pixmap to a QLabel. I've tried using
QPixmap pix(QByteArray((const char*)imgBlob->pbData, imgBlob->cbData));
but that returns a null pixmap. How can I achieve that?
Solution
If the image is a bitmap, use the QBitmap::fromData
function to create the QPixmap
. It is documented here.
Or use QPixmap::loadFromData
to allow Qt to attempt to detect the data format based on information in the image header.