[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
- 该信号在初始化ListWidget时候不触发,没有选中项做clear()的时候不触发。
- 一定要注意,当ListWidget中有Item被选中,并且需要作clear()操作的时候,会直接给槽函数发送参数= -1的信号。有时候还送发送一个参数=0的信号。
措施:
- 初始化后 connect
- clear()之前 disconnect