我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用PyQt4.QtCore.Qt.ItemIsEnabled()。
def addItem(self, row, data): """ This function add a item on a row :param row: the row's number :param data: the information :return: None """ # state can be filtered, closed or open # data[3] is state if data[3] in ["open"]: self.tableWidget.setVerticalHeaderItem(row, QTableWidgetItem(QIcon().fromTheme('list-add'), '')) else: self.tableWidget.setVerticalHeaderItem(row, QTableWidgetItem(QIcon().fromTheme('dialog-error'), '')) for i, d in enumerate(data): item = QTableWidgetItem(d) item.setFlags(Qt.ItemIsEnabled) self.tableWidget.setItem(row, i, item)
def updateList(self): """Update sample values list""" # get number of samples try: N=int(self.leNumberOfSamples.text()) except ValueError: N=0 return # re-generate sample list self.lwSampleValues.clear() for i in range(N): value=self.settings['minV']+(self.settings['maxV']-self.settings['minV'])*i/(N-1) self.lwSampleValues.addItem(str(value)) self.lwSampleValues.item(i).setFlags(Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable) # store number of samples self.N=N # update preview self.updatePreview()
def insertParams(self, position, distance, startAngle, endAngle): if position > self.tableWidget.rowCount(): self.tableWidget.insertRow(position-1) item = QTableWidgetItem('{:.4f}'.format(self.unitDistance(distance))) item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled) self.tableWidget.setItem(position-1, 2, item) item = QTableWidgetItem('{:.4f}'.format(startAngle)) item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled) self.tableWidget.setItem(position-1, 0, item) item = QTableWidgetItem('{:.4f}'.format(endAngle)) item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled) self.tableWidget.setItem(position-1, 1, item)
def flags(self, index): if index.isValid() and self.isDir(index): return Qt.ItemIsDropEnabled | Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsDragEnabled else: return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsDragEnabled
def __init__(self, parent=None): super(CustomTableWidgetItem, self).__init__(parent) self.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)