Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QPixmap.loadFromData(...) fails for a valid PNG
duckman last edited by
QPixmap.loadFromData(...) fails when trying to load a PNG from a byte array retrieved from a database. The PNG appears valid because after writing the bytes to a file it opened correctly in a PNG viewer.
The code is as follows:
pixmapReturn.loadFromData((const uchar *)diagram.c_str(),strlen(diagram.c_str()),"PNG");
Chris Hennes last edited by
If you dump it to a file like in your test, but then load it with
QPixmap::load()does it work?
What class is
My guess is that
strlendoesn't return what you expect. That function returns the length of a string which is determined by the terminating null-character. The binary data of an image can contains myriads of null-character.