title: How to select parent QListWidgetItem on click of Child Widgets?
body: <p>I have a GUI where a QListWidget is the central widget.  The QListWidgetItems are composed of a custom widget that include a Graphics area and a QTable.  </p>
  
  <p>When I click on the graphics area, or on the table, the parent QListWidgetItem is not selected</p>
  
  <p>See Picture of the GUI I'm working on</p>
  
  <p><img src="https://i.imgur.com/JRwJUKq.png" alt="Gui" title="gui"></p>
  
  <p>The red border around the top QListWidgetItem indicates that is the one that is currently selected.  </p>
  
  <p>From the Input on the table in the second QListWidgetItem, you can see I'm inputting text into the table widget there.  </p>
  
  <p>How can I make it so that if I click anywhere on that QListWidgetItem, including its child widgets, that the corresponding item is selected?</p>
  
  <p>For reference, here is some of the relevant code:</p>
  
  <pre><code>class MainWindow(QMainWindow):
      move_splitter = Signal(int, int)
  
      def __init__(self):
          super().__init__()
  
          # stuff
  
          self.panels = QListWidget()
          self.panels.setAcceptDrops(True)
          self.panels.setDragEnabled(True)
          self.panels.setDragDropMode(QAbstractItemView.InternalMove)
          self.panels.setStyleSheet("QListWidget::item:selected \
          { border: 1px solid red }")
          self.panels.setSelectionMode(QAbstractItemView.SingleSelection)
          self.setCentralWidget(self.panels)
  
          # more stuff
  
  
      def add_panel(self):
          insert_item = QListWidgetItem()
          # Panel inherits from QWidget
          new_panel = Panel(parent=insert_item,
                            splitter_pos=self.initialSplitterPosition)
          self.move_splitter.connect(new_panel.setSplitterPosition)
          new_panel.slider_position.connect(self.slotSplitterPosition)
          insert_item.setSizeHint(new_panel.sizeHint())
          insert_item.setFlags(insert_item.flags() | Qt.ItemIsAutoTristate)
          insert_item.setCheckState(Qt.PartiallyChecked)
          self.panels.insertItem(self.panels.currentRow() + 1, insert_item)
          self.panels.setItemWidget(insert_item, new_panel)
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>With the suggestion of implementing an event filter, I created the following subclass of my table</p>
  
  <pre><code>class ControlTable(QTableWidget):
      focusReceived = Signal()
  
      def __init__(self, parent=None):
          super().__init__()
  
      def focusInEvent(self, event):
          if event.type() == QFocusEvent.gotFocus:
              self.focusReceived.emit()
          QTableWidget.focusInEvent(self, event)
  </code></pre>
  
  <p>In my panel function, I created a signal and a slot to capture that signal and emit a signal to the MainWindow with which QListWidgetItem should be selected</p>
  
  <pre><code>class Panel(QWidget):
      slider_position = Signal(int, int)
      select_me = Signal(QObject)
  
      def __init__(self, parent=None, splitter_pos=[]):
          # stuff
          self.table = ControlTable()
          self.table.focusReceived.connect(self.childWidgetFocus)
          # more stuff
  
      @Slot()
      def childWidgetFocus(self):
          parent = self.parent_item
          self.select_me.emit(parent)
  </code></pre>
  
  <p>In my mainwindow class I also added</p>
  
  <pre><code>def add_panel(self):
      insert_item = QListWidgetItem()
      new_panel = Panel(parent=insert_item,
                        splitter_pos=self.initialSplitterPosition)
      new_panel.parent_item = insert_item
      new_panel.select_me.connect(self.changeSelection)
      # more stuff
  
  @Slot(QObject)
  def changeSelection(self, item):
      item.setSelected(True)
  </code></pre>
  
  <p>While the code runs, the change of selection is not happening, am I implementing the wrong event filter?</p>
  
  <p>EDIT2:</p>
  
  <p>Got it working, was using the wrong event filter type, I needed to use <code>QEvent.FocusIn</code>, but now that I look at my code, and looking at the function I'm overwriting, that if statement is unnecessary it would seem.</p>
  
  <p>I also had to change the signal pass type from QObject to QListWidgetItem.</p>