PDA

View Full Version : mouseMoveEvent(QMouseEvent* event), event->button()



faraslacks
17th December 2008, 06:06
I realise drag&drop actions on QTableView. My reimplemented mouseMoveEvent() looks so:


void
MyClass::mouseMoveEvent(QMouseMove* event)
{
qDebug() << event->button();
if (event->button() == Qt::LeftButton) {
int distance = (event->pos() - fPressPos).manhattanLength();
if (distance > QApplication::startDragDistance()) {
startDrag();
}
}
QTableView::mouseMoveEvent(event);
}

I execute my application and tried to move mouse with pressed left button above my widget. In debug messages I see 0. And function did not enter first condition. So move event called, but QMouseEvent not contains information about buttons pressed. I have not idea why it happening.

faraslacks
17th December 2008, 06:22
Oops, I solved my trouble myself... The condition must looks like this:



if (event->buttons() & Qt::LeftButton) {
// code here
}