Skip to content

QImage::loadFromData() and QImage::fromData()

Ivailo Monev edited this page Jul 17, 2016 · 3 revisions

This was done in https:/fluxer/katie/commit/81c6f05fe41d69431240bb14037da77bd0b76dce, the methods actually need the data to be char* not uchar* and this avoids reinterpret_cast which should reduce compilation times.

No source compatible methods are in place because you should evaluate how to handle this in your projects and you can always cast the data yourself. For an example:

uchar* mydata;
...
QImage myimage;
myimage.loadFromData(mydata, strlen(mydata))
...

Should be changed to:

uchar* mydata;
...
QImage myimage;
myimage.loadFromData(reiterpret_cast<const char*>(mydata), strlen(mydata))
...

Or even better, with Qt4 compatibility:

uchar* mydata;
...
QImage myimage;
#ifndef QT_KATIE
myimage.loadFromData(mydata, strlen(mydata))
#else
myimage.loadFromData(reiterpret_cast<char*>(mydata), strlen(mydata))
#endif
...