title: How to Change the Focus from QListWidget to QLineEdit, If I press only any Alphabets (A-Z, a-z) or numbers(0 - 9)?
body: <p><strong>Face a problem to change the focus from QListWidget to QLineEdit</strong>. </p>
  
  <p>If we press <strong>down_arrow</strong> or <strong>up_arrow</strong> from QLineEdit, focus changed from QLineEdit to Qlistwidget and press <strong>left_arrow</strong> or <strong>back_space</strong> from QListWidget, focus change from QListwidget to QLineEdit.</p>
  
  <p>Suppose <strong>Focus in QListWidget</strong>, Now I press <strong>Any alphabets or numbers ( A -z or a -z or 0 - 9), How to change the focus from QListwidget to QLineEdit</strong> and appear that pressed key value in QLineEdit Box. (For example, If I press "H" from QListWidget, focus change from QListWidget to QLineEdit and the Character "H" appears in last(n th)  postition)</p>
  
  <pre><code>import sys
  from PyQt5.QtGui import *
  from PyQt5.QtWidgets import *
  from PyQt5.QtCore import *
  
  item = ["Python", "Python 2.7", "Python 2.9", "Python 3.5", "Python 3.7", "National", "Zebra",
          "Apple", "X Ray", "Boat", "Tiger", "Item001", "Item002", "Item003", "Item004", "Item005",
          "001Item", "002Item", "003Item", "004Item", "005Item", "Ball", "Cat", "Dog", "Fish",
          "Gold Fish", "Star Fish", "2821", "2822", "2823", "2811", "2812", "2813"]
  flag = 2
  
  
  class Event_Handler(QWidget):
      def __init__(self):
          super().__init__()
  
          self.setMinimumSize(350, 600)
          self.textbox = QLineEdit()
          self.textbox.installEventFilter(self)
          self.textbox.textChanged.connect(self.func_textbox_textchanged)
  
          self.listbox_dummy = QListWidget()
          self.listbox_dummy.addItems(item)
  
          self.listbox = QListWidget()
          self.listbox.installEventFilter(self)
          self.listbox.addItems(item)
  
          self.label_1 = QLabel("Item Starts With (Alt+S)")
          self.label_2 = QLabel("Item Contains    (Alt+C)")
          self.label_3 = QLabel("Item Ends With   (Alt+E)")
  
          vbox1 = QVBoxLayout()
          vbox1.addWidget(self.textbox)
          vbox1.addWidget(self.listbox)
          vbox1.addWidget(self.label_1)
          vbox1.addWidget(self.label_2)
          vbox1.addWidget(self.label_3)
          self.setLayout(vbox1)
  
      def func_textbox_textchanged(self):
          global search_text, search_text_lenth, total_listbox_items, startitem_rowno, enditem_rowno, \
              startitem_count, containitem_count, enditem_count, item_normal, item_startswith, item_contains, \
              item_endswith, flag
  
          search_text = self.textbox.text()
          search_text_length = len(search_text)
  
          item_normal = self.listbox_dummy.findItems("*", Qt.MatchWildcard)
          item_startswith = self.listbox_dummy.findItems(search_text, Qt.MatchStartsWith)
          item_contains = self.listbox_dummy.findItems(search_text, Qt.MatchContains)
          item_endswith = self.listbox_dummy.findItems(search_text, Qt.MatchEndsWith)
  
          k = 0
          dummy_list = []
          for i in item_contains:
              if ((i.text().lower())[0:search_text_length]) == (search_text.lower()):
                  dummy_list.append(k)
                  startitem_rowno = (dummy_list[0])
                  enditem_rowno = (dummy_list[-1])
              k = k + 1
  
          startitem_count = len(item_startswith)
          containitem_count = len(item_contains)
          enditem_count = len(item_endswith)
  
          if search_text_length == 1:
              flag = 1
  
          self.listbox.clear()
  
          if flag == 1:
              self.func_item_startswith()
          elif flag == 2:
              self.func_item_contains()
          elif flag == 3:
              self.func_item_endswith()
          elif flag == 0:
              self.func_item_contains()
          else:
              self.func_item_normal()
  
          if startitem_count == 0:
              flag = 2
              self.func_item_contains()
  
      def func_item_startswith(self):
          global flag
          flag = 1
          self.listbox.clear()
  
          if startitem_count &gt; 0:
              for item in item_startswith:
                  self.listbox.addItem(item.text())
          else:
              print("No Matching from start item")
  
      def func_item_contains(self):
          global flag
          flag = 2
          self.listbox.clear()
  
          if containitem_count &gt; 0:
              for item in item_contains:
                  self.listbox.addItem(item.text())
          else:
              print("No Matching from contains item")
  
      def func_item_endswith(self):
          global flag
          flag = 3
          self.listbox.clear()
  
          if enditem_count &gt; 0:
              for item in item_endswith:
                  self.listbox.addItem(item.text())
          else:
              print("No Matching from end item")
  
      def func_item_normal(self, normal_count=None):
          global falg
          flag = 0
          self.listbox.clear()
  
          if normal_count &gt; 0:
              for item in item_normal:
                  self.listbox.addItem(item.text())
  
      def eventFilter(self, source, event):
          global startitem_rowno, enditem_rowno
  
          if event.type() == QEvent.KeyPress and source is self.textbox:
  
              if event.modifiers() == Qt.AltModifier and event.key() == Qt.Key_S:
                  self.func_item_startswith()
                  return True
              if event.key() == Qt.Key_C and event.modifiers() == Qt.AltModifier:
                  self.func_item_contains()
                  return True
              if event.key() == Qt.Key_E and event.modifiers() == Qt.AltModifier:
                  self.func_item_endswith()
                  return True
              if event.key() == Qt.Key_Down:
                  startitem_rowno = 0
                  if flag != 2:
                      startitem_rowno = 0
  
                  self.listbox.setFocus()
                  self.listbox.setCurrentRow(startitem_rowno)
  
              if event.key() == Qt.Key_Up:
                  enditem_rowno = len(self.listbox) - 1
                  if flag != 2:
                      enditem_rowno = len(self.listbox) - 1
                  self.listbox.setFocus()
                  self.listbox.setCurrentRow(enditem_rowno)
  
              if event.key() == Qt.Key_Return:
                  if len(self.listbox) == 1:
                      self.listbox.setCurrentRow(0)
                      self.textbox.setText(self.listbox.currentItem().text())
                      prin = self.listbox.currentItem().text()
  
          if event.type() == QKeyEvent.KeyPress and source is self.listbox:
  
              if event.key() == Qt.Key_Left or event.key() == Qt.Key_Backspace:
                  self.textbox.setFocus()
  
              if event.key() == Qt.Key_Return:
                  self.textbox.setText(self.listbox.currentItem().text())
                  self.textbox.setFocus()
  
  
          return super(Event_Handler, self).eventFilter(source, event)
  
  if __name__ == '__main__':
      myapp = QApplication(sys.argv)
      mywin = Event_Handler()
      mywin.show()
      sys.exit(myapp.exec_())
  </code></pre>