Hi, I think this is possible the other way round. Construct a QByteArray, cast it to memory_view and create the numpy array with np.from_buffer(...). For example:
>>> import numpy as np >>> from PySide2.QtCore import QByteArray >>> a = QByteArray(20000, 0) >>> npa = np.frombuffer(memoryview(a), dtype=np.uint8) >>> npa.dtype dtype('uint8') >>> npa.size 20000 >>> npa[0] 0 >>> npa[0] = 5 >>> npa[0] 5 >>> a[0] b'\x05' >>> a[0] = b'x' >>> a[0] b'x' >>> npa[0] 120 >>> Best regards Christoph On 16.10.20 09:31, 許友綸 wrote: > hi, QByteArray consturctor can take both bytes and bytearray as its > argument > The docs says it makes its own copy. I want a python buffer(numpy) > changing in real-time to be plotted/processed in QML. > > However, fromRawData only takes bytes which is immutable type! Wish it > can also be able to pass other buffer protocol types. > > appreciate your help, thank you > > -Tim > > _______________________________________________ > PySide mailing list > PySide@qt-project.org > https://lists.qt-project.org/listinfo/pyside
_______________________________________________ PySide mailing list PySide@qt-project.org https://lists.qt-project.org/listinfo/pyside