问题描述:
在提交表格数据之后,需要重新调用获取数据函数来刷新,但获取函数中包含有按钮信号的槽函数。然而,存在一个bug,重复调用获取数据函数会导致按钮信号重复发送的问题,每当用户执行xuanke函数并多次调用self.index3()时,每次调用都会导致按钮信号的槽函数重新连接一次。这意味着每次点击按钮,都会执行xuanke函数的逻辑多次,导致重复的执行和不符合预期的结果。
Bug 影响:
该bug会导致按钮的信号槽函数重复执行,从而导致不符合预期的结果出现。这可能引起程序逻辑错误、操作重复或数据异常等问题,影响用户体验和软件功能的正确性。
代码复现:
def index3(self):
# 获取数据逻辑
# 此处省略……
# 按钮信号
# 当用户点击确定按钮所发送的信号
self.xs.pushButton.clicked.connect(self.xuanke)
# 获取表中触发的信号
self.xs.tableWidget_2.clicked.connect(self.on_clicked)
def xuanke(self):
# 提交数据逻辑
# 此处省略……
# 清空全部行
self.xs.tableWidget_2.setRowCount(0)
self.xs.tableWidget.setRowCount(0)
# 重新获取一遍选课数据
self.index3()
解决方法:
在刷新数据之前,可以尝试断开按钮的信号连接,以防止在刷新数据时按钮信号的重复触发。这种方法适用于大多数的信号重叠问题。但是处于那种多种多重信号的情况下,有些会失灵,最终解决方法是将全部信号作为一个函数,这样子当执行获取数据函数的时候,就不会再携带信号重新发起信号。
def Signal(self):
# 按钮信号
# 当用户点击确定按钮所发送的信号
self.xs.pushButton.clicked.connect(self.xuanke)
# 获取表中触发的信号
self.xs.tableWidget_2.clicked.connect(self.on_clicked)
def index3(self):
# 获取数据逻辑
# 此处省略......
def xuanke(self):
# 提交数据逻辑
# 此处省略......
# 清空全部行
self.xs.tableWidget_2.setRowCount(0)
self.xs.tableWidget.setRowCount(0)
# 重新获取一遍选课数据
self.index3()
文章有(15)条网友点评
6
好好好
goodgood
Setup type:
Full installation
Selected components:
UltraVNC Server
UltraVNC Viewer
UltraVNC Repeater
Start Menu folder:
UltraVNC
Additional tasks:
Server configuration:
Register UltraVNC Server as a system service
Start or restart UltraVNC service
UltraVNC-xxxx-Setup.exe /silent /dir=”C:\Program Files\UltraVNC” /components=”Server,Viewer,Repeater” /startmenu=”UltraVNC” /registerservice /startservice
https://github.com/qiuapeng921/DnfHelper-Python/blob/master/game/auto.py
https://nnfp.jss.com.cn/7C0=0GoBH=-MzMF
https://nnfp.jss.com.cn/aIZVgRPBH=-QoaQ
体育,科技领域,国际局势,网络安全
https://nnfp.jss.com.cn/9SMRfc0e5K-11HAk
x = float(input(“请输入赔率A:”))
y = float(input(“请输入赔率b:”))
f = float(input(“本金”))
if x*y > x+y:
a = int(f/(1.9+2.5)*1.9)
b = int(f/(1.9+2.5)*2.5)
c = int((x*y*f)/(x + y)-f)
print(f”a:{x},b:{y}”)
print(f”a赔率的下:{b}”)
print(f”b的赔率下:{a}”)
print(f”利润:{c}”)
else:
pass
https://drissionpage.cn/browser_control/browser_object
https://www.drissionpage.cn/ChromiumPage/tab/
cookie:
__jdu=17253464604201399230075; o2State={%22webp%22:true%2C%22avif%22:true}; shshshfpa=761b0f88-d55c-bd8c-0cab-711ff630b6c2-1725346461; shshshfpx=761b0f88-d55c-bd8c-0cab-711ff630b6c2-1725346461; TrackID=1JUYW8ubyx1kZuQr4YtvI3zeVapwezBurqF3s93xiuVORZ5g056vlsT7BNfcEnPPpHpIix0QZNkabzP3nJa6UEI7ya122eQ0hReL0fmhFMnFbg-b23Rba1Tp4dkovF09a; thor=C5F8D3DC15167D282E58D21B3621A87D02727E17B91F556A000051E8F80C0AF3405F37FEA05AC20ED763E28B90E72DA24A3EE7A91614CD08416B859456DEC6AA11DECA1012AD8F389F83C072E2752683DC5812DD13399EE58AF7DEC39A85BDE6032F0330ED816AD350B029D5F3B477250FCA3EADA1D3EC7F12EF0D8AD992C3F1DE883781767A7F6E040EF3E7B4CB86E8F7C8CA38B9B0DB0CE4CA3B5693351C5F; light_key=AASBKE7rOxgWQziEhC_QY6yaIC-Xae5lXMUltiLi7Cp0ayEuD8sp9VbgdZNxXXXA3pWqWLeA; pinId=LrgtT5Xg-Ze1QSaE0TWwMA; pin=jd_tEzXRwemPTgX; unick=jd_pc7r2zt265ln84; areaId=19; PCSYCityID=CN_440000_440300_0; user-key=2c87c219-e7bc-436f-af42-983e8e38aa4c; ipLoc-djd=19-1607-6675-62147.6243938404; ipLocation=%u5e7f%u4e1c; 3AB9D23F7A4B3C9B=SFHTFUBVIBUA6SAIK2MAHK33ULGKBMTLL2FU4T7WOBHAY76T34SVNAKZ46KJPJQQQGCJHA2HBH5EY3FDMSMFEWUABY; unpl=JF8EAKxnNSttXU1TDBsFHhVCTQ5RWw5fS0dWbWJWUg5fSVwGHVJJEkN7XlVdWBRLFx9ubhRUXVNJUA4bAisSE3teVVxcDkwRBWphNWRaWEIZRElPKxEQe1xkXlsLTxUGaGICVVhbSlQHEwoYEBFKW1BuXDhMFwpfVzVRXVlLVQYaBx0UIEptVl5cCEoUAGdnAmQWNkoZBR0BHxAVTFhTX1gLShcBZ28GVlxZTVA1GjIY; __jda=76161171.17253464604201399230075.1725346460.1730859606.1731036911.9; __jdb=76161171.1.17253464604201399230075|9.1731036911; __jdc=76161171; __jdv=76161171|lianmeng__10__ntp.msn.cn|t_2030767747_|tuiguang|47681646c7b44bf1ad34b7b63927ac1b|1731036911349; 3AB9D23F7A4B3CSS=jdd03SFHTFUBVIBUA6SAIK2MAHK33ULGKBMTLL2FU4T7WOBHAY76T34SVNAKZ46KJPJQQQGCJHA2HBH5EY3FDMSMFEWUABYAAAAMTBHLRRDQAAAAACWWL3TQQMEMAY4X; _gia_d=1; flash=3_f1ZOgXSeRJtA7NC1ZnHA7JW6fUarmCuvSp1Kx_R6sNA4KHKJSUhtW9lgQqGULWS-hlnchSoxNkIaEb58pu2f42wL0jFa6obsGStKoQHgc4uqpPtwOEJoSKqxndg1_QlI5am980a_OB7MyaZDi_lF8n3rdPrnqOBtQ5_WXMGUaLg3Ko9n77vl; umc_count=1; UseCorpPin=jd_tEzXRwemPTgX; shshshfpb=BApXSJq7fCvZA7aGYJxtTOL5iGGhN9gcYBmd1Y05r9xJ1MhiJy4C2
http://www.july2x.top/wp-content/uploads/2024/11/DFE1DD25-26A1-4C19-A875-03B1A5A9D70C-1.png