sc = new QGraphicsScene(this); ui->graphicsView->setScene(sc); ui->graphicsView->setSceneRect(0,0,300,300); QGraphicsLineItem *li = new QGraphicsLineItem(1,1,100,100); li->setPen(QPen(Qt::black)); QGraphicsLineItem *li2 = new QGraphicsLineItem(100,10,20,200); li2->setPen(QPen(Qt::black)); QGraphicsItemGroup *ig = new QGraphicsItemGroup; ig->addToGroup(li); ig->addToGroup(li2); sc->addItem(ig); ig->moveBy(100,100); ig->rotate(10); QPointF p1,p2; p1 = ig->mapToScene(ig->mapFromItem(ig,QPointF(1,100))); p2 = ig->mapToScene(ig->mapFromItem(ig,QPointF(200,100))); QGraphicsLineItem *li3 = new QGraphicsLineItem(p1.x(),p1.y(),p2.x(),p2.y()); li3->setPen(QPen(Qt::black)); ig->addToGroup(li3);
p1 = ig->mapToScene(ig->mapFromItem(ig,QPointF(1,100))); p2 = ig->mapToScene(ig->mapFromItem(ig,QPointF(200,100)));
p1 = ig->mapToScene(QPointF(1,100)); p2 = ig->mapToScene(QPointF(200,100));