Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top