QSurfaceDataProxy not working in QML
-
Hi
I am trying to use QSurfaceDataProxy from python in QML but I keep getting this error "Unable to assign [undefined] to QSurfaceDataProxy*".
Can you help with what could be the cause? Thank you
Here are the code snippets
python snippet
class Surface2(QObject): name_changed = Signal(QSurfaceDataProxy) simulator_nameChanged = Signal(str) def __init__(self, parent=None): QObject.__init__(self, parent) self.surfaceproxy = QSurfaceDataProxy() # self.surfaceseries = QSurface3DSeries(self.surfaceproxy) self.create_data() self.test_name = "blue" @Property(str, notify=simulator_nameChanged) def color_name(self): return self.test_name def create_data(self): x = [1,2,3] y = [3,4,5] z = [6,7,8] data_arr = [] for i, item in enumerate(x): row = [QSurfaceDataItem(QVector3D(x[i], y[i], z[i]))] print(row[0].x()) data_arr.append(row) self.surfaceproxy.resetArray(data_arr) print(self.surfaceproxy.rowCount()) return self.surfaceproxy @Property(QSurfaceDataProxy, notify=name_changed) def output(self): return self.surfaceproxy engine.rootContext().setContextProperty("surfaceDataModel", surface_model)
qml snippet
Surface3D { id: surfacePlot width: parent.width height: parent.height theme: Theme3D { type: Theme3D.ThemeStoneMoss font.family: "STCaiyun" backgroundColor: surfaceDataModel.color_name font.pointSize: 35 colorStyle: Theme3D.ColorStyleRangeGradient Surface3DSeries { itemLabelFormat: "Pop density at (@xLabel N, @zLabel E): @yLabel" dataProxy: surfaceDataModel.output } }
-
Have you tried exposing the proxy to QML using decorators as done in the file system example https://doc.qt.io/qtforpython-6/examples/example_quickcontrols_filesystemexplorer.html ?
-
Have you tried exposing the proxy to QML using decorators as done in the file system example https://doc.qt.io/qtforpython-6/examples/example_quickcontrols_filesystemexplorer.html ?
@friedemannkleint
Thank you. Will try it