本文整理汇总了Python中PyQt5.QtWidgets.QListView.show方法的典型用法代码示例。如果您正苦于以下问题:Python QListView.show方法的具体用法?Python QListView.show怎么用?Python QListView.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QListView
的用法示例。
在下文中一共展示了QListView.show方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MyModel
# 需要导入模块: from PyQt5.QtWidgets import QListView [as 别名]
# 或者: from PyQt5.QtWidgets.QListView import show [as 别名]
class MyModel(QAbstractListModel):
def __init__(self, parent):
super().__init__(parent)
def rowCount(self, parent):
return 10
def data(self, index, role):
if role == Qt.DisplayRole:
return "{}".format(index.row())
return QVariant()
if __name__ == '__main__':
app = QApplication(sys.argv)
list_view = QListView()
my_model = MyModel(None)
list_view.setModel(my_model)
list_view.show()
# The mainloop of the application. The event handling starts from this point.
# The exec_() method has an underscore. It is because the exec is a Python keyword. And thus, exec_() was used instead.
exit_code = app.exec_()
# The sys.exit() method ensures a clean exit.
# The environment will be informed, how the application ended.
sys.exit(exit_code)