void MainWindow::resizeItem() { for (int i = 0; i < 10; i++) { QGraphicsRectItem* theFrame = item1; QPointF P1(100 - (7.0 * i)/3.0, 50 -(5.0*i)/3.0); graphicsSheet->addPoint("P1", P1); graphicsSheet->addPoint("pos", theFrame->pos()); QPointF P2i = QPointF(theFrame->rect().width(), theFrame->rect().height()); QPointF P2 = theFrame->mapToScene(P2i); qDebug() << "P1:" << P1; qDebug() << "P2:" << P2; graphicsSheet->addPoint("P2", P2); QTransform t; t.rotate(-theFrame->rotation()); t.translate(-P1.x(), -P1.y()); QPointF P2t = t.map(P2); // qDebug() << "P2t:" << P2t; // OK /*************************/ QPointF P3(P2t.x()/2, P2t.y()/2); // qDebug() << "P3:" << P3; QTransform t2; t2.translate(P1.x(), P1.y()); t2.rotate(theFrame->rotation()); QPointF P3t = t2.map(P3); //// qDebug() << "P3t:" << P3t; // OK graphicsSheet->addPoint("P3t", P3t); QTransform t3; t3.translate(P3t.x(), P3t.y()); t3.rotate(-theFrame->rotation()); t3.translate(-(P3t.x()), -(P3t.y())); QPointF newPos = t3.map(P1); QSizeF newSize = QSizeF(P2t.x(), P2t.y()); graphicsSheet->addPoint("newPos", newPos); RectItem* item1 = new RectItem(QRectF(newPos.x(), newPos.y(), newSize.width(), newSize.height())); qreal angle = 30; QPointF center2 = QPointF(item1->rect().width() / 2, item1->rect().height() / 2); item1->setTransformOriginPoint(center2); item1->setRotation(angle); graphicsSheet->scene()->addItem(item1); } }