我创建了自己的类(视图和场景)来显示我添加到其中的图像和对象,甚至在我的视图中实现了放大/缩小功能,但现在我必须添加新功能,我什至不知道如何开始寻找它。
不幸的是 - 我什至不知道如何寻找一些基本的东西,因为“移动”和类似的东西是指拖动对象。
编辑 1
void CustomGraphicView::mouseMoveEvent(QMouseEvent *event)
{
if(event->buttons() == Qt::MidButton)
{
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
translate(event->x(),event->y());
}
}
Run Code Online (Sandbox Code Playgroud)
试过这个 - 但它正在反向工作。