Hello,
I re-implement mouse event handlers in a subclass of QGraphicsScene and have a problem with the mouseMoveEvent() function.
The following code works (i.e. when I press the left/middle/right buttons, hold and move, I have the text displayed):
{
std::cout<<"hehe"<<std::endl;
}
void Scene::mouseMoveEvent(QGraphicsSceneMouseEvent* e)
{
std::cout<<"hehe"<<std::endl;
}
To copy to clipboard, switch view to plain text mode
but the following does not (nothing happens even if I press the left button):
{
if(e->button()==Qt::LeftButton) std::cout<<"hehe"<<std::endl;
}
void Scene::mouseMoveEvent(QGraphicsSceneMouseEvent* e)
{
if(e->button()==Qt::LeftButton) std::cout<<"hehe"<<std::endl;
}
To copy to clipboard, switch view to plain text mode
The following code also works
if(e->button()==Qt::LeftButton) std::cout<<"hehe"<<std::endl;
}
void Scene::mousePressEvent(QGraphicsSceneMouseEvent* e){
if(e->button()==Qt::LeftButton) std::cout<<"hehe"<<std::endl;
}
To copy to clipboard, switch view to plain text mode
Hope it's not a bug of Qt and somebody can help.
Thank you so much.
Bookmarks