将鼠标单击事件添加到使用QtCreator创建的QGraphicsView中

Add mouse click event to QGraphicsView created with QtCreator

本文关键字:创建 QtCreator QGraphicsView 单击 鼠标 事件 添加      更新时间:2023-10-16

有没有一种方法可以在不创建另一个类并继承QGraphicsView的情况下为创建的QGraphicsView创建事件?我想知道是否有这样的方法:

ui->gView->AddEvent(click, functionName);

谢谢。

如果要处理视图的鼠标单击事件,请在视图中安装事件过滤器并监视MouseButtonPress事件。