focus on the next qlistwidget item while there are hidden items

A more elegant solution is to use moveCursor to get the QModelIndex and set the current index to the view:

def __ctrl(self):
    shorcut = self.sender()
    index = QModelIndex()
    if shorcut.key() == QKeySequence(Qt.Key_Up):
        index = self._list_widget.moveCursor(
            QAbstractItemView.MoveUp, Qt.NoModifier
    elif shorcut.key() == QKeySequence(Qt.Key_Down):
        index = self._list_widget.moveCursor(
            QAbstractItemView.MoveDown, Qt.NoModifier
    if index.isValid():

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top