【问题标题】:QlistWidget how to select items one by oneQlistWidget如何一一选择项目
【发布时间】:2017-10-04 23:42:14
【问题描述】:

我想要打开图像序列并将所有图像加载到列表中;我希望当我单击一个名为 next 的按钮时,当前列表索引从 1 更改为 2,而不是从 2 更改为 3 ......等最后一帧。 这段代码总是给我最后一帧

 self.nextbtn.clicked.connect(self.changeitem)
 def changeitem(self):
        self.listWidget.count()
        count_list = self.listWidget.count()
        self.listWidget.setCurrentRow(0)
        for i in range(count_list):
            self.listWidget.setCurrentRow(i+1)

【问题讨论】:

  • 我找到了简单的解决方案:(更新)
  • 请不要在您的问题中发布解决方案,而是将其作为新答案。
  • 因为在评论中我无法编写代码;它看起来像一个文本

标签: python-3.x pyqt4 pyqt5 qlistwidget


【解决方案1】:

解决方案:

def changeitem(self):
    cur = self.listWidget.currentRow()
    self.listWidget.setCurrentRow(cur+1)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-18
    • 2023-04-03
    • 2016-11-24
    • 2021-11-13
    • 1970-01-01
    • 2018-04-22
    相关资源
    最近更新 更多