本文整理汇总了Python中PyQt5.QtWidgets.QAbstractItemView.SingleSelection方法的典型用法代码示例。如果您正苦于以下问题:Python QAbstractItemView.SingleSelection方法的具体用法?Python QAbstractItemView.SingleSelection怎么用?Python QAbstractItemView.SingleSelection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QAbstractItemView
的用法示例。
在下文中一共展示了QAbstractItemView.SingleSelection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5.QtWidgets import QAbstractItemView [as 别名]
# 或者: from PyQt5.QtWidgets.QAbstractItemView import SingleSelection [as 别名]
def __init__(self, client, *args, **kwargs):
self.client = client
self.macros = []
QWidget.__init__(self, *args, **kwargs)
self.setLayout(QVBoxLayout())
self.layout().setContentsMargins(0, 0, 0, 0)
buttonLayout = QHBoxLayout()
new_button = QPushButton("New")
add_button = QPushButton("Add...")
remove_button = QPushButton("Remove")
new_button.clicked.connect(self.new_macro)
add_button.clicked.connect(self.browse_macro)
remove_button.clicked.connect(self.remove_selected)
# Set up table
self.macroListModel = IntMacroListModel(self, self.client)
self.macroListView = QTableView()
self.macroListView.setModel(self.macroListModel)
self.macroListView.verticalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
self.macroListView.verticalHeader().hide()
self.macroListView.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
self.macroListView.horizontalHeader().hide()
self.macroListView.horizontalHeader().setStretchLastSection(True)
self.macroListView.setSelectionBehavior(QAbstractItemView.SelectRows)
self.macroListView.setSelectionMode(QAbstractItemView.SingleSelection)
buttonLayout.addWidget(new_button)
buttonLayout.addWidget(add_button)
buttonLayout.addWidget(remove_button)
buttonLayout.addStretch()
self.layout().addWidget(self.macroListView)
self.layout().addLayout(buttonLayout)
示例2: __init__
# 需要导入模块: from PyQt5.QtWidgets import QAbstractItemView [as 别名]
# 或者: from PyQt5.QtWidgets.QAbstractItemView import SingleSelection [as 别名]
def __init__(self, client, repeater_widget=None, macro_widget=None, *args, **kwargs):
QWidget.__init__(self, *args, **kwargs)
self.allow_save = False
self.client = client
self.repeater_widget = repeater_widget
self.macro_widget = macro_widget
self.query = []
self.req_view_widget = None
self.setLayout(QStackedLayout())
self.layout().setContentsMargins(0, 0, 0, 0)
self.tableModel = ReqListModel(self.client)
self.tableView = QTableView()
self.tableView.setModel(self.tableModel)
self.tableView.verticalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
self.tableView.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
self.tableView.verticalHeader().hide()
self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows)
#self.tableView.setSelectionMode(QAbstractItemView.SingleSelection)
self.tableView.horizontalHeader().setStretchLastSection(True)
self.tableView.selectionModel().selectionChanged.connect(self.on_select_change)
self.tableModel.dataChanged.connect(self._paint_view)
self.tableModel.rowsInserted.connect(self._on_rows_inserted)
self.requestsChanged.connect(self.set_requests)
self.requestsSelected.connect(self._updated_selected_request)
self.selected_reqs = []
self.layout().addWidget(self.tableView)
self.layout().addWidget(QLabel("<b>Loading requests from data file...</b>"))