本文整理汇总了Python中AnyQt.QtGui.QStandardItemModel.itemFromIndex方法的典型用法代码示例。如果您正苦于以下问题:Python QStandardItemModel.itemFromIndex方法的具体用法?Python QStandardItemModel.itemFromIndex怎么用?Python QStandardItemModel.itemFromIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtGui.QStandardItemModel
的用法示例。
在下文中一共展示了QStandardItemModel.itemFromIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OWPreprocess
# 需要导入模块: from AnyQt.QtGui import QStandardItemModel [as 别名]
# 或者: from AnyQt.QtGui.QStandardItemModel import itemFromIndex [as 别名]
#.........这里部分代码省略.........
self.preprocessormodel = ppmodel
self.controler.setModel(ppmodel)
if ppmodel is not None:
self.preprocessormodel.dataChanged.connect(self.__on_modelchanged)
self.preprocessormodel.rowsInserted.connect(self.__on_modelchanged)
self.preprocessormodel.rowsRemoved.connect(self.__on_modelchanged)
self.preprocessormodel.rowsMoved.connect(self.__on_modelchanged)
self.__update_overlay()
def __update_overlay(self):
if self.preprocessormodel is None or \
self.preprocessormodel.rowCount() == 0:
self.overlay.setWidget(self.flow_view)
self.overlay.show()
else:
self.overlay.setWidget(None)
self.overlay.hide()
def __on_modelchanged(self):
self.__update_overlay()
self.commit()
@Inputs.data
@check_sql_input
def set_data(self, data=None):
"""Set the input data set."""
self.data = data
def handleNewSignals(self):
self.apply()
def __activated(self, index):
item = self.preprocessors.itemFromIndex(index)
action = item.data(DescriptionRole)
item = QStandardItem()
item.setData({}, ParametersRole)
item.setData(action.description.title, Qt.DisplayRole)
item.setData(action, DescriptionRole)
self.preprocessormodel.appendRow([item])
def buildpreproc(self):
plist = []
for i in range(self.preprocessormodel.rowCount()):
item = self.preprocessormodel.item(i)
desc = item.data(DescriptionRole)
params = item.data(ParametersRole)
if not isinstance(params, dict):
params = {}
create = desc.viewclass.createinstance
plist.append(create(params))
if len(plist) == 1:
return plist[0]
else:
return preprocess.preprocess.PreprocessorList(plist)
def apply(self):
# Sync the model into storedsettings on every apply.
self.storeSpecificSettings()
preprocessor = self.buildpreproc()
if self.data is not None:
self.error()