문제

How do I allow my listwidget to show the highlighted item upon execution?

Currently for mine, it highlights the item but I have to scroll down every time I execute my program to see if it's highlighting the correct item.. (My list items are very huge)

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)

I know that qlistwidget has a property/slot called scrollToItem and I strongly suspect that I have written wrong. Can someone advise me?

도움이 되었습니까?

해결책

Well i think this should solve your problem .

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

    for item in self.serverItemList.findItems(currentItem, Qt.MatchFixedString):
       serverItemList.setCurrentItem(item)

This seems to do the thing for me.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top