load gif into QMovie object from data (no file)

后端 未结 1 1594
说谎
说谎 2021-01-23 15:46

I have read through many questions, most of which not on this site, and they all mention QMovie must be called with a file name, like this

anim = QtGui.QMovie(\"         


        
相关标签:
1条回答
  • 2021-01-23 16:11

    The QMovie constructor can take a QIODevice as first argument, so the gif data can be loaded via a QBuffer:

    a = QtCore.QByteArray(data)
    b = QtCore.QBuffer(a)
    b.open(QtCore.QIODevice.ReadOnly)
    m = QtGui.QMovie(b, 'GIF')
    
    0 讨论(0)
提交回复
热议问题