Hi ,all

Recently, I use tableview to make an alarm window which ,obviously, show the alarms in in the scada system.

The requirement is: If the operator is permitted by his privilege to ack the alarm in the alarm window,he can select the alarm, if not, he cannot select.

I inherit QTableView and rewrite the function
Qt Code:
  1. QItemSelectionModel::SelectionFlags QAbstractItemView::selectionCommand(const QModelIndex &index, const QEvent *event) const
To copy to clipboard, switch view to plain text mode 
the code is like this:
Qt Code:
  1. QItemSelectionModel::SelectionFlags CAckTableView::selectionCommand ( const QModelIndex & index, const QEvent * event) const
  2. {
  3. if (the operator does not have privilege){
  4. return QItemSelectionModel::NoUpdate | QItemSelectionModel::current;
  5. }
  6.  
  7. return QTableView::selectionCommand(index,event);
  8.  
  9. }
To copy to clipboard, switch view to plain text mode 
Then I found the selcet event QEvent::MouseButtonPress act
properly,but QEvent::MouseMove is very strange.

The selection behavior of QEvent::MouseMove is depend on the last item the mouse pointer on. That is hard to describe clearly. Finally I probably find the problem in the qt source code. In
Qt Code:
  1. void QAbstractItemView::mouseMoveEvent(QMouseEvent *event)
To copy to clipboard, switch view to plain text mode 
,
call
Qt Code:
  1. setSelection(selectionRect, command);
To copy to clipboard, switch view to plain text mode 
,

the parameter is
Qt Code:
  1. QPoint topLeft;
  2. if (d->selectionMode != SingleSelection)
  3. topLeft = d->pressedPosition - d->offset();
  4. else
  5. topLeft = bottomRight;
  6. QPoint bottomRight = event->pos();
  7. QRect selectionRect = QRect(topLeft, bottomRight);
  8.  
  9. QModelIndex index = indexAt(bottomRight);
  10. QItemSelectionModel::SelectionFlags command = selectionCommand(index, event);
To copy to clipboard, switch view to plain text mode 

In coclusion the problem is: the selection of MouseMove event is depend on whether the operator has the privilge on the last item the mouse pointed. The privilege cannot work!!

I think the problem is in the
Qt Code:
  1. void QAbstractItemView::mouseMoveEvent(QMouseEvent *event)
To copy to clipboard, switch view to plain text mode 
.
Did anyone meet such problem? Please give me a clue! Thank you!