如何在QGraphicsScene中启用拖动? [英] How to enable dragging in QGraphicsScene?
本文介绍了如何在QGraphicsScene中启用拖动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在 QGraphicsScene
中放置两张图片。一个是固定的,另一个是可移动的。但是我只能将这些图片放入 QGraphicsScene
中,但无法移动它们。我该如何实现?
I'm trying to put two pictures in the QGraphicsScene
. One is fixed and the other one is movable. But I succeed only in putting those pictures in the QGraphicsScene
, I can't move them. How can I achieve this?
推荐答案
您必须确保该项目可移动。看看 QGraphicsItem :: setFlag 。
You have to make sure the item is movable. Have a look at QGraphicsItem::setFlag.
您必须执行以下操作:
myImageItem->setFlag(QGraphicsItem::ItemIsMovable, true);
这篇关于如何在QGraphicsScene中启用拖动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文