'''
【简介】
PyQT5中表格头为自适应模式例子
'''
import sys
from PyQt5.QtWidgets import (QWidget, QTableWidget, QHBoxLayout, QApplication, QTableWidgetItem, QHeaderView)
class Table(QWidget):
def init (self):
super(). init ()
self.initUI()
if name == ' main ':
app = QApplication(sys.argv)
example = Table()
example.show()
sys.exit(app.exec_())
[cpp] view plaincopysetEditTriggers(QAbstractItemView1 在编程中.
QAbstractItemView,而QAbstractItemView方法setEditTriggers可以设置是否可以编辑.
QAbstractItemView:DoubleClicked 2 Editing starts when an item is double clicked:AnyKeyPressed 16 Editing starts when any key is pressed over an item::,因此只要是继承自QAbstractItemView的其它类控件都可以设置为可否编辑:SelectedClicked 4 Editing starts when clicking on an already selected item.
QAbstractItemView:,而且方法一致:CurrentChanged 1 Editing start whenever current item changes,如1所示:。
QAbstractItemView的编辑触发事件如下:
Constant
Value
Description
QAbstractItemView
2 由QTableWidget引申,则使用如下代码即可.
QAbstractItemView:.
QAbstractItemView:EditKeyPressed 8 Editing starts when the platform edit key has been pressed over an item:.
QAbstractItemView,若是想设置QTableWidget为不可编辑:AllEditTriggers 31 Editing starts for all above actions:NoEditTriggers):
因为QTableWidget继承自QAbstractItemView::NoEditTriggers 0 No editing possible
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)