C++ QGraphicsSellipseitem不可移动
我在一个MAC OS X/QT5.3小部件应用程序中工作,我试图使C++ QGraphicsSellipseitem不可移动,c++,qt,qgraphicsview,C++,Qt,Qgraphicsview,我在一个MAC OS X/QT5.3小部件应用程序中工作,我试图使QGraphicsEllipseItem在QGraphicsItemGroup中可移动。我正在设置所有需要的标志,但椭圆不会移动 以下是我的代码(略去了不重要的简化代码): 现在,该点已显示,但不可移动。状态如下:- QGraphicsSiteMgroup类提供了一个容器,该容器将一组项视为单个项 因此,您不应该期望在组中移动单个项目。如果要整体移动组,则需要在组本身上设置标志 由于QGraphicsItem和派生类可以设置为父类
QGraphicsEllipseItem
在QGraphicsItemGroup
中可移动。我正在设置所有需要的标志,但椭圆不会移动
以下是我的代码(略去了不重要的简化代码):
现在,该点已显示,但不可移动。状态如下:-
QGraphicsSiteMgroup类提供了一个容器,该容器将一组项视为单个项
因此,您不应该期望在组中移动单个项目。如果要整体移动组,则需要在组本身上设置标志
由于QGraphicsItem和派生类可以设置为父类,因此可以通过创建一个QGraphicsItem来实现所需的效果,该QGraphicsItem可以用作所有要组合在一起的类的父类
这将允许移动单独的图形项目成员。其中的其他项目是可移动的吗?不,没有。我有点不知所措,因为我知道项目在那里,它们被显示,它们在顶部,但它们不可移动。我将使用pixmap进行尝试,以确保这不仅仅是薄椭圆问题。请注意,在GraphicsSiteMgroup中,“所有子项的所有事件和几何体都合并在一起”。那么,在将它们添加到组中之前,它们是可移动的吗?@Merlin069 awesome thoughtproces;)yipee ki-kay!:)这让我烦了很久。:)
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);
}