【问题标题】:How to display the highlighted item within a list?如何在列表中显示突出显示的项目?
【发布时间】:2014-02-27 01:46:02
【问题描述】:

如何让我的listwidget 在执行时显示突出显示的项目?

目前对于我来说,它会突出显示该项目,但每次执行程序时我都必须向下滚动以查看它是否突出显示正确的项目..(我的列表项目非常大)

def currentItemSelect(self):
    currentItem = os.environ['ITEM']            
    self.serverItemList.clearSelection()

    for item in self.serverItemList.findItems(currentItem, Qt.MatchFixedString):
       item.setSelected(True)
       serverItemList.scrollToItem(item)

我知道qlistwidget 有一个名为scrollToItem 的属性/插槽,我强烈怀疑我写错了。有人可以给我建议吗?

【问题讨论】:

    标签: python scroll pyqt pyqt4 qlistwidget


    【解决方案1】:

    我认为这应该可以解决您的问题。

    def currentItemSelect(self):
        currentItem = os.environ['ITEM']            
        self.serverItemList.clearSelection()
    
        for item in self.serverItemList.findItems(currentItem, Qt.MatchFixedString):
           serverItemList.setCurrentItem(item)
    

    这似乎对我有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-09
      • 2012-02-02
      • 2013-12-22
      • 1970-01-01
      • 1970-01-01
      • 2018-11-10
      • 1970-01-01
      • 2013-06-12
      相关资源
      最近更新 更多