void View::rotate(){ QGraphicsItemGroup *group = new QGraphicsItemGroup; group->setPos(figure_one->pos().x(), figure_one->pos().y()); group = scene->createItemGroup(scene->items(group->mapToItem(group, group->pos().x()-20, group->pos().y()-20, 100, 80))); group->setRotation(90); scene->destroyItemGroup(group);}
C++ (Qt)void Rotate( QGraphicsItem & item, qreal angle_degree, const QPointF & center ){ QTransform t1, t2, t3; t1.translate(-center.x(), -center.y()); t2.rotate(angle_degree); t3.translate(center.x(), center.y()); item.setTransform(t1 * t2 * t3);}
void View::Rotate(){ QGraphicsItemGroup *group = new QGraphicsItemGroup; //group->setPos(figure_one->pos().x()-20, figure_one->pos().y()-20); group->setTransformOriginPoint(figure_one->pos().x(), figure_one->pos().y()); group = scene->createItemGroup(scene->items(figure_one->pos().x()-20, figure_one->pos().y()-20, 80, 60)); group->rotate(90); scene->destroyItemGroup(group);}
C++ (Qt) QGraphicsItemGroup *group = new QGraphicsItemGroup; //group->setPos(figure_one->pos().x()-20, figure_one->pos().y()-20); group = scene->createItemGroup(scene->items(figure_one->pos().x()-20, figure_one->pos().y()-20, 80, 60)); group->setTransform( QTransform().translate( figure_one->pos().x(), figure_one->pos().y() ).rotate( 90).translate( -x, -y ) ); scene->destroyItemGroup(group);