PDA

View Full Version : What's happened to the QGraphicsSceneMouseEvent::button () function?



Kiko007
27th August 2019, 14:53
Hello!
A few days ago I posted a post on forum.qt.io entitled What happened to the QGraphicsSceneMouseEvent::button() function?
Here I do the same to see if someone has happened or tried the same code.



Hi!!
I have next code;

void Test::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{

qDebug()<<"MouseMove"<<event->button();
if (event->button() != Qt::LeftButton){
//Always execute
return;
}
QGraphicsScene::mouseMoveEvent(event);
}

Output:
MouseMove Qt::NoButton

Why does the QGraphicsSceneMouseEvent::button() function inside the mouseMoveEvent function return Qt::Nobutton?
However mousePressEvent and mouseReleaseEvent function work fine :(
Output :
MousePress Qt::LeftButton
MouseMove Qt::NoButton
MouseMove Qt::NoButton
MouseRelease Qt::LeftButton



I have:
Qt Creator 4.9.1
Based on Qt 5.12.3 (MSVC 2017, 32 bit)
Built on May 26 2019 21:17:08
From revision 168e91b618
Copyright 2008-2019 The Qt Company Ltd. All rights reserved.
The version is Qt opensource-windows-x86-5.13.0.
On Windows 10 Pro

You can run "Diagram Scene Example" and executed the same code just after mousePressEvent, mouseMoveEvent and mouseReleaseEvent function, in the DiagramScene class ...
Thanks!!!