pyqt qt4 QTableView how to disable sorting for certain columns?
So I have a QTableView and I only want to let column sorting on column 1 but not column2. Naturally I tried to installEventFilter on QHeaderView or QTableView , but MouseButtonPress event is not being passed unless you installEventFilter on QApplication Now if when eventFilter is called, the target object is always the top level widget although event.pos() is actually relative to the header or tablecell depending on where you click. So we cannot use QHeaderView.rect().contains(event.pos()) to find out if the user clicks on the header because you get false positive when you click on the top