self.tablemodel.setData(self.tablemodel.rowCount(None), newitemindex,0)
self.tableView_ControlsInStrip.resizeColumnsToContents()
self.tableView_ControlsInStrip.selectRow(0)
self.tablemodel.setData(self.tablemodel.rowCount(None), newitemindex,0)
self.tableView_ControlsInStrip.resizeColumnsToContents()
self.tableView_ControlsInStrip.selectRow(0)
To copy to clipboard, switch view to plain text mode
def __init__(self, datain, headerdata, parent=None):
"""
Args:
datain: a list of lists\n
headerdata: a list of strings
"""
self.arraydata = datain
self.headerdata = headerdata
def rowCount(self, parent):
return len(self.arraydata)
def columnCount(self, parent):
if len(self.arraydata) > 0:
return len(self.arraydata[0])
return 0
def data(self, index, role):
if not index.isValid():
# elif role == Qt.BackgroundColorRole:
# #print (self.arraydata[index.row()][7])
# if self.arraydata[index.row()][7] == 'Stage':
# return QBrush(Qt.blue)
# elif self.arraydata[index.row()][7] == 'Sound':
# return QBrush(Qt.yellow)
# elif self.arraydata[index.row()][7] == 'Light':
# return QBrush(Qt.darkGreen)
# elif self.arraydata[index.row()][7] == 'Mixer':
# return QBrush(Qt.darkYellow)
# else:
# return QBrush(Qt.darkMagenta)
#
elif role != QtCore.Qt.DisplayRole:
return QtCore.
QVariant(self.
arraydata[index.
row()][index.
column()])
def setData(self, index, value, role):
self.arraydata.extend([supportedcontroltypes[index]])
self.dataChanged.emit(self.createIndex(0,0),
self.createIndex(self.rowCount(None),self.columnCount(None)))
def headerData(self, col, orientation, role):
if orientation == QtCore.Qt.Horizontal and role == QtCore.Qt.DisplayRole:
return QtCore.
QVariant(self.
headerdata[col
])
class MyTableModel(QtCore.QAbstractTableModel):
def __init__(self, datain, headerdata, parent=None):
"""
Args:
datain: a list of lists\n
headerdata: a list of strings
"""
QtCore.QAbstractTableModel.__init__(self, parent)
self.arraydata = datain
self.headerdata = headerdata
def rowCount(self, parent):
return len(self.arraydata)
def columnCount(self, parent):
if len(self.arraydata) > 0:
return len(self.arraydata[0])
return 0
def data(self, index, role):
if not index.isValid():
return QVariant()
# elif role == Qt.BackgroundColorRole:
# #print (self.arraydata[index.row()][7])
# if self.arraydata[index.row()][7] == 'Stage':
# return QBrush(Qt.blue)
# elif self.arraydata[index.row()][7] == 'Sound':
# return QBrush(Qt.yellow)
# elif self.arraydata[index.row()][7] == 'Light':
# return QBrush(Qt.darkGreen)
# elif self.arraydata[index.row()][7] == 'Mixer':
# return QBrush(Qt.darkYellow)
# else:
# return QBrush(Qt.darkMagenta)
#
elif role != QtCore.Qt.DisplayRole:
return QtCore.QVariant()
return QtCore.QVariant(self.arraydata[index.row()][index.column()])
def setData(self, index, value, role):
self.arraydata.extend([supportedcontroltypes[index]])
self.dataChanged.emit(self.createIndex(0,0),
self.createIndex(self.rowCount(None),self.columnCount(None)))
def headerData(self, col, orientation, role):
if orientation == QtCore.Qt.Horizontal and role == QtCore.Qt.DisplayRole:
return QtCore.QVariant(self.headerdata[col])
return QtCore.QVariant()
To copy to clipboard, switch view to plain text mode
Bookmarks