Hello, as the title says I am trying to implement a context menu that appears on left click if a whole column is selected in a TableView.

In my MainWindow I have these attributes

Qt Code:
  1. private:
  2. QString mFilePath;
  3. DatasetModel model;
  4. myTabView* view;
  5. DataFrame data;
  6. TabSelModel* selModel;
To copy to clipboard, switch view to plain text mode 
where myTabView is just a reimplemented QTableView. I installed an event filter in the constructor of the MainWindow like this view->installEventFilter(this); and I implemented di eventfilter in the Main Window like this

Qt Code:
  1. bool MainWindow::eventFilter(QObject *watched, QEvent *e)
  2. {
  3. if(watched==view && e->type()==QEvent::MouseButtonPress)
  4. {
  5. QModelIndexList idxl = view->selectedIndexes();
  6. QMouseEvent *mou = static_cast<QMouseEvent*>(e);
  7. if(mou->button()==Qt::RightButton && selModel->ColSelected.first)
  8. {
  9. ShowContextMenu(mou->pos());
  10. return true;
  11. }
  12. }
  13. return QWidget::eventFilter(watched,e);
  14. }
To copy to clipboard, switch view to plain text mode 
Where ColSelected is a QPair implemented in a slot of my TabSelModel (a reimplemented QItemSelectionModel). The slot looks like this

Qt Code:
  1. void TabSelModel::CheckSelection(const QModelIndex& mod,)
  2. {
  3. qDebug() << "Inside mod.column=" << mod.column();
  4. QModelIndexList ls = selectedIndexes();
  5.  
  6. foreach(QModelIndex i, ls)
  7. qDebug() << i.column() << "," << i.row();
  8.  
  9. if(isColumnSelected(mod.column(),mod)) //never evaluates to true
  10. ColSelected = qMakePair(true,mod);
  11. else
  12. ColSelected.first = false;
  13. }
To copy to clipboard, switch view to plain text mode 
which is connected to a simple SIGNAL(currentChanged()) from the selection model. The first condition never evaluates to true. Using the qDebug() I realised that the first time I select the first column of the table the output is just

Qt Code:
  1. Inside mod.column= 0
To copy to clipboard, switch view to plain text mode 
But when I select the next column I get

Qt Code:
  1. Inside mod.column= 1
  2. 0 , 0
  3. 0 , 1
  4. 0 , 2
  5. 0 , 3
  6. ...
  7. 0, 66
To copy to clipboard, switch view to plain text mode 

meaning that mod.column() evaluates to 1 and selectedIndexes()[0].column() evaluates to 0 while they should be the same. Why is that? And how can I fix this?