本文整理汇总了Python中PyQt5.QtCore.QModelIndex.row方法的典型用法代码示例。如果您正苦于以下问题:Python QModelIndex.row方法的具体用法?Python QModelIndex.row怎么用?Python QModelIndex.row使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QModelIndex
的用法示例。
在下文中一共展示了QModelIndex.row方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: selectSample
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import row [as 别名]
def selectSample(self,index: QModelIndex):
print("select row",index.row(),"column",index.column(),"id",index.internalId())
self.currentWell=self.sampleTable.item(index.row(),1).text()
print("sample item=",self.sampleTable.item(index.row(),0).text())
self.currentSample=int(self.sampleTable.item(index.row(),0).text())
#self.plateTable.selectRow(index.row())
self.refreshAll()
示例2: setData
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import row [as 别名]
def setData(self, index: QModelIndex, value, role=Qt.DisplayRole):
if role == Qt.CheckStateRole:
proto_label = self.labels[index.row()]
proto_label.fuzz_me = value
self.protolabel_fuzzing_status_changed.emit(proto_label)
elif role == Qt.EditRole:
if len(value) > 0:
self.labels[index.row()].name = value
return True
示例3: selectPlate
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import row [as 别名]
def selectPlate(self,index: QModelIndex):
print("select row",index.row(),"column",index.column(),"id",index.internalId())
rec=self.plateTable.model().record(index.row())
for i in range(rec.count()):
print(rec.fieldName(i),"=",rec.field(i).value())
self.currentPlate=rec.field(0).value()
#self.plateTable.selectRow(index.row())
self.currentSample=None
self.currentWell=None
self.refreshAll()
示例4: update_question_type_tools
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import row [as 别名]
def update_question_type_tools(self, current: QModelIndex = None):
if current is not None:
self.ui.remove_question_type_button.setDisabled(False)
top_index = current.sibling(current.row() - 1, current.column())
bottom_index = current.sibling(current.row() + 1, current.column())
self.ui.move_up_question_type_button.setDisabled(not top_index.isValid())
self.ui.move_down_question_type_button.setDisabled(not bottom_index.isValid())
else:
self.ui.remove_question_type_button.setDisabled(True)
self.ui.move_up_question_type_button.setDisabled(True)
self.ui.move_down_question_type_button.setDisabled(True)
示例5: selectRun
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import row [as 别名]
def selectRun(self,index: QModelIndex):
print("select row",index.row(),"column",index.column(),"id",index.internalId())
pkIndex=index.sibling(index.row(),0)
self.currentRun=self.runsTable.model().data(pkIndex).value()
pgmIndex=index.sibling(index.row(),3)
self.currentProgram=self.runsTable.model().data(pgmIndex).value()
self.currentPlate=None
self.currentSample=None
self.currentWell=None
#self.runsTable.selectRow(index.row())
self.refreshAll()
示例6: setData
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import row [as 别名]
def setData(self, index: QModelIndex, value, role=Qt.DisplayRole):
if role == Qt.CheckStateRole:
if index.column() == 0:
message_type = self.message_types[index.row()]
message_type.show = value
self.message_type_visibility_changed.emit(message_type)
elif role == Qt.EditRole:
if index.column() == 0 and value:
message_type = self.message_types[index.row()]
message_type.name = value
self.message_type_name_edited.emit(value)
return True
示例7: setData
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import row [as 别名]
def setData(self, index: QModelIndex, value, role=Qt.DisplayRole):
if role == Qt.CheckStateRole:
proto_label = self.message_type[index.row()]
proto_label.show = value
self.protolabel_visibility_changed.emit(proto_label)
elif role == Qt.EditRole:
proto_label = self.message_type[index.row()]
proto_label.name = value
self.message_type.change_field_type_of_label(proto_label,
self.controller.field_types_by_caption.get(value, None))
self.protolabel_type_edited.emit()
return True
示例8: data
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import row [as 别名]
def data(self, qModelIndex: QModelIndex, role = None):
if not qModelIndex.row() >= 0:
raise RuntimeError("row = {}".format(qModelIndex.row()))
if role == TaskDataRole:
result = self.adapterMap.at(qModelIndex.row())
return result
elif role == Qt.DisplayRole:
return self.data(qModelIndex, role = TaskDataRole).name
elif role == CreationTimeRole:
dt = QDateTime.fromTime_t(
self.data(qModelIndex, role = TaskDataRole).creationTime)
return dt
elif role == TaskClassRole:
return self.data(qModelIndex, TaskDataRole).klass
示例9: setData
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import row [as 别名]
def setData(self, index: QModelIndex, value, role=None):
if index.row() == 0 and role == Qt.CheckStateRole:
if bool(value) != self.show_unassigned:
self.show_unassigned = bool(value)
self.show_state_changed.emit()
elif role == Qt.CheckStateRole:
try:
if self.participants[index.row()-1].show != value:
self.participants[index.row()-1].show = value
self.show_state_changed.emit()
except IndexError:
return False
return True
示例10: setData
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import row [as 别名]
def setData(self, index: QModelIndex, value, role=Qt.DisplayRole):
if role != Qt.EditRole:
return True
i = index.row()
j = index.column()
a = self.get_alignment_offset_at(i)
j -= a
hex_chars = ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f")
if i >= len(self.protocol.messages):
return False
if self.proto_view == 0 and value in ("0", "1") and self.__pad_until_index(i, j + 1):
self.protocol.messages[i][j] = bool(int(value))
self.display_data[i][j] = int(value)
elif self.proto_view == 1 and value in hex_chars and self.__pad_until_index(i, (j + 1) * 4):
converted_j = self.protocol.convert_index(j, 1, 0, self.decode, message_indx=i)[0]
bits = "{0:04b}".format(int(value, 16))
for k in range(4):
self.protocol.messages[i][converted_j + k] = bool(int(bits[k]))
self.display_data[i][j] = int(value, 16)
elif self.proto_view == 2 and len(value) == 1 and self.__pad_until_index(i, (j + 1) * 8):
converted_j = self.protocol.convert_index(j, 2, 0, self.decode, message_indx=i)[0]
bits = "{0:08b}".format(ord(value))
for k in range(8):
self.protocol.messages[i][converted_j + k] = bool(int(bits[k]))
self.display_data[i][j] = ord(value)
else:
return False
self.data_edited.emit(i, j)
return True
示例11: setData
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import row [as 别名]
def setData(self, index: QModelIndex, value, role=None):
if role == Qt.EditRole:
i, j = index.row(), index.column()
label = self.message_type[i] # type: SimulatorProtocolLabel
if j == 0:
label.name = value
ft = self.controller.field_types_by_caption.get(value, FieldType("Custom", FieldType.Function.CUSTOM))
label.field_type = ft
elif j == 1:
label.display_format_index = value
elif j == 2:
label.value_type_index = value
elif j == 3:
if label.value_type_index == 0:
message = label.parent()
try:
bits = util.convert_string_to_bits(value, label.display_format_index,
target_num_bits=label.end-label.start)
message.plain_bits[label.start:label.end] = bits
except ValueError:
pass
elif label.value_type_index == 2:
label.formula = value
elif label.value_type_index == 3:
label.external_program = value
elif label.value_type_index == 4:
label.random_min = value[0]
label.random_max = value[1]
self.dataChanged.emit(self.index(i, 0),
self.index(i, self.columnCount()))
self.protocol_label_updated.emit(label)
return True
示例12: data
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import row [as 别名]
def data(self, index: QModelIndex, role=Qt.DisplayRole):
i, j = index.row(), index.column()
if role == Qt.DisplayRole:
try:
lbl = self.message_type[i]
except IndexError:
return False
if j == 0:
return lbl.name
elif j == 1:
return self.message.get_label_range(lbl, view=self.proto_view, decode=True)[0] + 1
elif j == 2:
return self.message.get_label_range(lbl, view=self.proto_view, decode=True)[1]
elif j == 3:
return lbl.color_index
elif j == 4:
return lbl.apply_decoding
elif role == Qt.TextAlignmentRole:
return Qt.AlignCenter
elif role == Qt.FontRole and j == 0:
font = QFont()
font.setItalic(self.message_type[i].field_type is None)
return font
else:
return None
示例13: setData
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import row [as 别名]
def setData(self, index: QModelIndex, value, role=Qt.EditRole):
if value == "":
return True
i = index.row()
j = index.column()
if i >= len(self.message_type):
return False
lbl = self.__get_label_at(i)
if j == 0:
lbl.name = value
type_before = type(lbl)
self.message_type.change_field_type_of_label(lbl, self.field_types_by_caption.get(value, None))
lbl = self.__get_label_at(i)
if type_before != ProtocolLabel or type(lbl) != ProtocolLabel:
self.special_status_label_changed.emit(lbl)
elif j == 1:
lbl.start = self.message.convert_index(int(value - 1), from_view=self.proto_view, to_view=0, decoded=True)[
0]
elif j == 2:
lbl.end = self.message.convert_index(int(value), from_view=self.proto_view, to_view=0, decoded=True)[0]
elif j == 3:
lbl.color_index = value
elif j == 4:
if bool(value) != lbl.apply_decoding:
lbl.apply_decoding = bool(value)
self.apply_decoding_changed.emit(lbl)
return True
示例14: data
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import row [as 别名]
def data(self, index: QModelIndex, role: int = TAG_ROLE) -> str:
row = self.languages[index.row()]
if role == self.NAME_ROLE:
return row[1]
elif role == self.TAG_ROLE:
return row[0]
return ""
示例15: data
# 需要导入模块: from PyQt5.QtCore import QModelIndex [as 别名]
# 或者: from PyQt5.QtCore.QModelIndex import row [as 别名]
def data(self, index: QModelIndex, role=Qt.DisplayRole):
if not index.isValid():
return None
i = index.row()
j = index.column()
device = self.get_device_at(i)
if role == Qt.DisplayRole:
if j == 0:
return self.backend_handler.DEVICE_NAMES[i]
elif j == 1:
if device.is_enabled:
if device.supports_rx and device.supports_tx:
device_info = "supports RX and TX"
elif device.supports_rx and not device.supports_tx:
device_info = "supports RX only"
elif not device.supports_rx and device.supports_tx:
device_info = "supports TX only"
else:
device_info = ""
else:
device_info = "disabled"
return device_info
elif j == 2:
return "" if device.has_native_backend else "not available"
elif j == 3:
return "" if device.has_gnuradio_backend else "not available"
elif role == Qt.CheckStateRole:
if j == 0 and (device.has_native_backend or device.has_gnuradio_backend):
return Qt.Checked if device.is_enabled else Qt.Unchecked
elif j == 2 and device.has_native_backend:
return Qt.Checked if device.selected_backend == Backends.native else Qt.Unchecked
elif j == 3 and device.has_gnuradio_backend:
return Qt.Checked if device.selected_backend == Backends.grc else Qt.Unchecked