【发布时间】:2014-07-28 08:01:54
【问题描述】:
我正在使用 MAC OS X / QT5.3 小部件应用程序,我正在尝试在 QGraphicsItemGroupmovable 中制作 QGraphicsEllipseItem。我正在设置所有需要的标志,但椭圆不会移动。
这是我的代码(省略不重要和简化):
QGraphicsView * view;
QGraphicsItemGroup * controlPoints;
//there are more groups
void setUp()
{
view = new QGraphicsView();
view->setRenderHint(QPainter::Antialiasing,true);
QGraphicsScene * scene = new QGraphicsScene(0,0,500,500);
view.setScene(scene);
controlPoints = new QGraphicsItemGroup();
//there are multiple groups and i need them to be in different depths(zvalues)
controlPoints->setZValue(2);
scene.addItem(controlPoints);
}
void AddPointsToGroup()
{
QGraphicsEllipseItem * controlPoint = new QGraphicsEllipseItem(100,100,6.5,6.5);
controlPoint->setFlag(QGraphicsItem::ItemIsMovable,true);
controlPoint->setFlag(QGraphicsItem::ItemIsSelectable,true);
controlPoint->setFlag(QGraphicsItem::ItemIsFocusable,true);
controlPoint->setFlag(QGraphicsItem::ItemSendsGeometryChanges);
controlPoints->addToGroup (controlPoint);
}
现在,该点已显示,但不可移动。
【问题讨论】:
-
里面还有其他可以移动的物品吗?
-
不,它们都不是。我有点不知所措,因为我知道物品在那里,它们被展示出来,它们在上面,但它们不能移动。
-
我会尝试使用像素图来确保它不仅仅是细椭圆问题。
-
请注意,在 GraphicsitemGroup 中“所有子项的所有事件和几何图形都合并在一起”。那么,在将它们添加到组之前,它们是否可以移动?
-
@Merlin069 很棒的思考过程 ;)
标签: c++ qt qgraphicsview