I am trying to implement a custom QGraphicsScene
, and when we press the left key, it allows dragging an item, for which I use QDrag
and pass the item data, then I overwrite the dropEvent
event where I get element and dropEvent
new parent. I think that QGraphicsPixmapItem
on top of another item could be tricky, so maybe the best option is to set it as the parentItem
.
However, I get the following error 'auto' not allowed in lambda parameter
and don't know exactly why
graphicsscene.h
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
graphicsscene.cpp
void GraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
auto its = items(QRectF(event->scenePos() - QPointF(1,1), QSize(3,3)));
auto val = std::find_if(its.constBegin(), its.constEnd(), [](auto const& it){ // <-- ERROR HERE
return it->type() > QGraphicsItem::UserType;
});
if(val == its.constEnd())
return;
if(event->button() == Qt::RightButton){
showContextMenu(event->scenePos());
}
else{
createDrag(event->scenePos(), event->widget(), *val);
}
}
Thanks for any insight about this.