Hi i thought QMovie could take QBuffer? This is my code.
a = QByteArray(img) b = QBuffer(a) self.movie = QMovie(b, 'GIF') Hi i thought QMovie could take QBuffer? This is my code.
a = QByteArray(img) b = QBuffer(a) self.movie = QMovie(b, 'GIF') You want to use the second constructor:
and as you see it is expected that the second argument is a QByteArray that can be replaced by bytes, so in the next part I show you an example:
import sys from PyQt5 import QtCore, QtGui, QtWidgets if __name__ == '__main__': app = QtWidgets.QApplication(sys.argv) # load data from path = "congratulations.gif" file = QtCore.QFile(path) if not file.open(QtCore.QIODevice.ReadOnly): sys.exit(-1) ba = file.readAll() buf = QtCore.QBuffer(ba) if not buf.open(QtCore.QIODevice.ReadOnly): sys.exit(-1) movie = QtGui.QMovie(buf, b"gif") w = QtWidgets.QLabel() w.setMovie(movie) movie.start() w.show() sys.exit(app.exec_())