python tablewidget单击事件_python - PyQt5如何给tablewidget添加点击事件?除了tablewidget还有什么具有scroll?...

本文介绍了如何在PyQt5中为TableWidget添加点击事件,并展示了动态加载数据到表格的示例。通过创建MyTableWidget类,设置编辑触发方式,并连接itemClicked信号到handleItemClick槽函数,实现点击单元格时打印其内容。同时,MainScene类中展示了搜索按钮触发时,从指定URL获取数据并填充到TableWidget的方法。
摘要由CSDN通过智能技术生成

怪我咯2017-04-18 09:05:561楼

1) 不能用label代替吧,毕竟不是一个东西

3) 见setColumnStretch说明

Sets the stretch factor of column column to stretch. The first column is number 0.

The stretch factor is relative to the other columns in this grid. Columns with a higher stretch factor take more of the available space.

The default stretch factor is 0. If the stretch factor is 0 and no other column in this table can grow at all, the column may still grow.

An alternative approach is to add spacing using addItem() with a QSpacerItem.

2) 感觉你tableWidget使用不规范,建议做成成员变量

self.tableWidget = None

然后contextGrid初始化,之后根据条数动态的往里面加数据。

import sys

from PyQt5.QtWidgets import *

from PyQt5.QtWidgets import *

import urllib.request as request

import Spider

class MyTableWidget(QTableWidget):

def __init__(self):

super().__init__

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值