I have the below lists in python, I need to plot these lists as x,y,z co-ordinates in Scatter 3d series qml type
USed AbstractTableModel to generate the cordinates using lists .py file:
class MyTableModel(QAbstractTableModel):
def __init__(self, x, y, z, parent=None):
super().__init__(parent)
self._data = list(zip(x, y, z))
def rowCount(self, parent=QModelIndex()):
return len(self._data)
def columnCount(self, parent=QModelIndex()):
return 3
def data(self, index, role=Qt.DisplayRole):
if role == Qt.DisplayRole:
return self._data[index.row()][index.column()]
return None
def roleNames(self):
roles = super().roleNames()
roles[Qt.UserRole + 1] = b'x'
roles[Qt.UserRole + 2] = b'y'
roles[Qt.UserRole + 3] = b'z'
return roles
def data(self, index, role=Qt.DisplayRole):
if role == Qt.DisplayRole or role >= Qt.UserRole:
column = index.column()
row = index.row()
if column == 0:
return self._data[row][0]
elif column == 1:
return self._data[row][1]
elif column == 2:
return self._data[row][2]
return None
class ListTab(QWidget):
init()
listx = [1,2,3]
listy = [4,5,6]
listz = [7,8,9]
# Create an instance of the model
model = MyTableModel(listx, listy, listz)
self.quickwidget = QQuickView()
self.quickwidget.rootContext().setContextProperty("**myModel**", model)
QML file:
Scatter3D { id: scatter3Dplot
Scatter3DSeries {
id: scatterSeriesPlot
ItemModelScatterDataProxy {
itemModel: **myModel*****// This needs to be generated from python using list1,list2,list3***
// Mapping model roles to scatter series item coordinates.
xPosRole: "x"
yPosRole: "y"
zPosRole: "z"
}
}
Here my plotting not happening. No errros and no plots.