QListWidget中currentRowChanged信号的坑

[signal] void QListWidget::currentRowChanged(int currentRow)

This signal is emitted whenever the current item changes.

currentRow is the row of the current item. If there is no current item, the currentRow is -1.

Note: Notifier signal for property currentRow.

有道翻译:

[signal] void QListWidget::currentRowChanged(int currentRow)

此信号在当前项发生更改时发出。

currentRow是当前项的行。如果没有当前项,则currentRow为-1。

注意:属性currentRow的通知信号。

坑就是返回值是 -1

  1. 该信号在初始化ListWidget时候不触发,没有选中项做clear()的时候不触发。
  2. 一定要注意,当ListWidget中有Item被选中,并且需要作clear()操作的时候,会直接给槽函数发送参数= -1的信号。有时候还送发送一个参数=0的信号。

措施:

  1. 初始化后 connect
  2. clear()之前 disconnect
  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值