python pyqt5 QTableWidget 设置表头

python pyqt5 QTableWidget 设置表头,第1张

'''

【简介】

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 plaincopy

setEditTriggers(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


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/11755874.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-18
下一篇 2023-05-18

发表评论

登录后才能评论

评论列表(0条)

保存