title: Access column name from a contextMenuEvent in PyQt
body: <p>Working with a <code>QTableView</code>, I added a  <code>contextMenuEvent</code> to the headers. I need to get access to the column header I clicked on to do things with the column name.</p>
  
  <p>Some code :</p>
  
  <pre><code>class MyTableView(QTableView):
      def __init__(self):
          super().__init__()
          self.horizontalHeader().setContextMenuPolicy(Qt.CustomContextMenu)
          self.horizontalHeader().customContextMenuRequested.connect(self.selectMenu)
  
  
      def selectMenu(self, event):
          """ A right click on a column name allows the info to be displayed in the graphView """
          menu = QMenu(self)
          selectAction = QAction("Display on graph", self)
          menu.addAction(selectAction)
          menu.popup(QCursor.pos())
          print(type(self.horizontalHeader())) # returns QHeaderView
  </code></pre>
  
  <p>Unfortunatly there is no function in the <code>QHeaderView</code> class to retrieve the header data.   </p>
  
  <p>I also tried to access the column using the <code>QTableView.columnAt()</code> function :</p>
  
  <pre><code>print(self.columnAt(QCursor.pos().x())) # returns -1
  </code></pre>
  
  <p>As you can see it doesn't work since the QCursor is not on a "valid index" according to the <code>QTableView</code> documentation.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Works using <code>event.x()</code> instead of <code>QCursor.pos().x()</code></p>
  
  <pre><code>print(self.columnAt(event.x())) # returns the column index or -1 if not a valid column
  </code></pre>