首先我的设置是
python3
requirements.txt
PyQt5>=5.12
pyqt3d>=5.12
pyopengl
example.py
from PyQt5.QtCore import *
from PyQt5.Qt3DCore import *
from PyQt5.Qt3DRender import *
class SomeDataGenerator(QBufferDataGenerator):
def __init__(self, some_bytes):
super().__init__()
self._bytes = some_bytes
def __call__(self):
return self._bytes
def __eq__(self, other):
return (self._bytes == other._bytes)
def __neq__(self, other):
return not (self._bytes == other._bytes)
def id(self):
return functorTypeId(SomeDataGenerator)
someBytes = QByteArray()
someBuffer = QBuffer(QBuffer.VertexBuffer)
someDataGenerator = SomeDataGenerator(someBytes)
someBuffer.setDataGenerator(someDataGenerator)
运行时输出:
$ python3 example.py
...
TypeError: PyQt5.Qt3DRender.QBufferDataGenerator cannot be instantiated or sub-classed
所以问题是我怎么打电话给QBuffer::setDataGenerator
?
我想做的一件大事:通过Qt3D
绑定用PyQt5
绘制点或任何东西。