本文整理汇总了Python中qtpy.QtCore.QModelIndex方法的典型用法代码示例。如果您正苦于以下问题:Python QtCore.QModelIndex方法的具体用法?Python QtCore.QModelIndex怎么用?Python QtCore.QModelIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtCore
的用法示例。
在下文中一共展示了QtCore.QModelIndex方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_testresults
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QModelIndex [as 别名]
def add_testresults(self, new_tests):
"""
Add new test results to the model.
Arguments
---------
new_tests : list of TestResult
"""
firstRow = len(self.testresults)
lastRow = firstRow + len(new_tests) - 1
for test in new_tests:
self.abbreviator.add(test.name)
self.beginInsertRows(QModelIndex(), firstRow, lastRow)
self.testresults.extend(new_tests)
self.endInsertRows()
self.emit_summary()
示例2: data
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QModelIndex [as 别名]
def data(self, index, role):
"""
Re-implemented to return the icon for the current index.
Parameters
----------
index : QtCore.QModelIndex
role : int
Returns
-------
Any
"""
if role == QtCore.Qt.DecorationRole:
iconString = self.data(index, role=QtCore.Qt.DisplayRole)
return qtawesome.icon(iconString, color=self._iconColor)
return super().data(index, role)
示例3: index
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QModelIndex [as 别名]
def index(self, row, column, parent=QModelIndex()):
"""
Construct index to given item of data.
If `parent` not valid, then the item of data is on the top level.
"""
if not self.hasIndex(row, column, parent): # check bounds etc.
return QModelIndex()
if not parent.isValid():
return self.createIndex(row, column, TOPLEVEL_ID)
else:
testresult_index = parent.row()
return self.createIndex(row, column, testresult_index)
示例4: parent
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QModelIndex [as 别名]
def parent(self, index):
"""Return index to parent of item that `index` points to."""
if not index.isValid():
return QModelIndex()
id = index.internalId()
if id == TOPLEVEL_ID:
return QModelIndex()
else:
return self.index(id, 0)
示例5: rowCount
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QModelIndex [as 别名]
def rowCount(self, parent=QModelIndex()):
"""Return number of rows underneath `parent`."""
if not parent.isValid():
return len(self.testresults)
if parent.internalId() == TOPLEVEL_ID and parent.column() == 0:
return len(self.testresults[parent.row()].extra_text)
return 0
示例6: columnCount
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QModelIndex [as 别名]
def columnCount(self, parent=QModelIndex()):
"""Return number of rcolumns underneath `parent`."""
if not parent.isValid():
return len(HEADERS)
else:
return 1
示例7: index
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QModelIndex [as 别名]
def index(self, row, column, parent):
if not self.hasIndex(row, column, parent):
return QtCore.QModelIndex()
if not parent.isValid():
parentItem = self.rootItem
else:
parentItem = parent.internalPointer()
childItem = parentItem.childItems[row]
if childItem:
return self.createIndex(row, column, childItem)
else:
return QtCore.QModelIndex()
示例8: parent
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QModelIndex [as 别名]
def parent(self, index):
if not index.isValid():
return QtCore.QModelIndex()
parentItem = index.internalPointer().parentItem
if parentItem == self.rootItem:
return QtCore.QModelIndex()
return self.createIndex(parentItem.row(), 0, parentItem)
示例9: rowCount
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QModelIndex [as 别名]
def rowCount(self, index=QModelIndex()):
"""Override Qt method."""
return len(self._rows)
示例10: columnCount
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QModelIndex [as 别名]
def columnCount(self, index=QModelIndex()):
"""Override Qt method."""
return 4