左侧item
(self, item)
| 44 | return |
| 45 | |
| 46 | def onItemClicked(self, item): |
| 47 | """左侧item""" |
| 48 | row = self.listWidget.row(item) # 获取点击的item的索引 |
| 49 | # 由于右侧的widget是按照命名widget_0 widget_1这样比较规范的方法,可以通过getattr找到 |
| 50 | widget = getattr(self, 'widget_%d' % row, None) |
| 51 | if not widget: |
| 52 | return |
| 53 | # 定位右侧位置并滚动 |
| 54 | self._blockSignals = True |
| 55 | self.scrollArea.verticalScrollBar().setSliderPosition(widget.pos().y()) |
| 56 | self._blockSignals = False |
| 57 | |
| 58 | |
| 59 | if __name__ == '__main__': |