Jus*_*tin 5 qt mouseevent qgraphicsscene
快速问题,为什么:
void roiwindow::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
QGraphicsScene::mouseMoveEvent(event);
qDebug() << event->button();
}
Run Code Online (Sandbox Code Playgroud)
当我在图形中移动光标的同时按住鼠标左键时,返回0而不是1.反正有没有让它返回1所以我可以告诉用户何时在图形切片上拖动鼠标.谢谢.
您可以通过查看buttons
属性来了解是否按下了左键:
if ( e->buttons() & Qt::LeftButton )
{
// left button is held down while moving
}
Run Code Online (Sandbox Code Playgroud)
希望有所帮助!