TableView->setMouseTracking(true);
TableView->installEventFilter (new TMMW(TableView));
Вернее ловится но раз из 100-1000!
C++ (Qt)
class TMMW : public QObject
{
Q_OBJECT
public:
TMMW(QObject *parent) : QObject(parent) {}
virtual ~TMMW() {}
virtual bool eventFilter ( QObject * watched, QEvent * event);
};
bool TMMW::eventFilter (QObject * watched, QEvent * event) {
QAbstractItemView* View = qobject_cast<QAbstractItemView*>(watched);
if(!View) {return false;}
if (event->type() == QEvent::MouseMove) {
QMessageBox msgBox;
msgBox.setText("QEvent::MouseMove");
msgBox.setIcon(QMessageBox::Information);
msgBox.exec();
}
return false;
}
Спасибо!
Вот что получилось:
C++ (Qt)
TableView->viewport()->setMouseTracking(true);
TableView->viewport()->installEventFilter(new TMMW(TableView));
bool TMMW::eventFilter (QObject * watched, QEvent * event) {
QWidget* Widget = qobject_cast<QWidget*>(watched);
if(!Widget) {return false;}
QAbstractItemView* View = qobject_cast<QAbstractItemView*>(Widget->parent());
if(!View) {return false;}
if (event->type() == QEvent::MouseMove) {
QMouseEvent* e = (QMouseEvent*)event;
QModelIndex ModelIndex = View->indexAt(e->pos());
if(ModelIndex.column() != 1 || ModelIndex.row() != 4) {return false;}
QMessageBox msgBox;
msgBox.setText("QEvent::MouseMove");
msgBox.setIcon(QMessageBox::Information);
msgBox.exec();
}
return false;
}