我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用PyQt4.QtCore.QAbstractTableModel()。
def __init__(self,ChannelList_obj,headers = [], keysurv=None, keyloop=None, keysta=None, parent = None): self.__headers=["station",u"g (\u00b5gal)",u"sd (\u00b5gal)","tiltx","tilty","temp (K)","dur (s)","rej","t (mn)","date/time"] QtCore.QAbstractTableModel.__init__(self, parent) self.unchecked = {} self.createArrayData(ChannelList_obj) self.keysurv=keysurv self.keyloop=keyloop self.keysta=keysta
def setData(self, index, value, role): """ if a row is unchecked, update the keepdata value to 0 setData launched when role is acting value is QtCore.Qt.Checked or QtCore.Qt.Unchecked """ if (role == QtCore.Qt.CheckStateRole and index.column() == 0): if value == QtCore.Qt.Checked: self.ChannelList_obj.keepdata[index.row()]=1 elif value == QtCore.Qt.Unchecked: self.unchecked[index] = value self.ChannelList_obj.keepdata[index.row()]=0 return True return QtCore.QAbstractTableModel.setData(self, index, value, role)
def __init__(self, seriesColumns,parent=None): QtCore.QAbstractTableModel.__init__(self, parent) self.seriesTable=[] self.seriesColumns=seriesColumns self.sortCol=0 self.sortOrder=Qt.AscendingOrder
def __init__(self, narray, headerdata, parent=None, *args): QAbstractTableModel.__init__(self, parent, *args) self._array = narray self.headerdata = headerdata
def __init__(self, narray, headerdata, row_headersdata, parent=None): QtCore.QAbstractTableModel.__init__(self, parent) self._array = narray self.headerdata = [str(x) for x in headerdata] self.row_headersdata = [str(x) for x in row_headersdata]
def headerData(self, col, orientation, role=Qt.DisplayRole): if role == Qt.DisplayRole and orientation == Qt.Horizontal: return self.headerdata[col] if role == Qt.DisplayRole and orientation != Qt.Horizontal: return self.row_headersdata[col] return QAbstractTableModel.headerData(self, col, orientation, role)
def data(self, index, role): # Displaying Data if role == QtCore.Qt.DisplayRole: # Sanity check if index.row() < 0 or index.row() > self.if_cfg.num_ifs(): return QtCore.QVariant() if index.column() == COLUMN_IFS: return self.if_cfg.get_if_for_idx(index.row()) if index.column() == COLUMN_MITM: return QtCore.QVariant() # Editing Data (Not Needed) if role == QtCore.Qt.EditRole: if index.column() == COLUMN_MITM: pass # Align text if role == QtCore.Qt.TextAlignmentRole: return QtCore.Qt.AlignCenter # Return internally managed checkbox state if role == QtCore.Qt.CheckStateRole: if_name = self.if_cfg.get_if_for_idx(index.row()) if index.column() == COLUMN_MITM: if self.if_cfg.is_mitm(if_name): return QtCore.Qt.Checked else: return QtCore.Qt.Unchecked if index.column() == COLUMN_OUT: if self.if_cfg.is_outbound(if_name): return QtCore.Qt.Checked else: return QtCore.Qt.Unchecked return QtCore.QVariant() ## Required methods to subclass QAbstractTableModel ## Optional methods for subclass of QAbstractTableModel