Diagonale distanz von QRect

Alles rund um die Programmierung mit Qt
Antworten
patrik08
Beiträge: 746
Registriert: 27. Februar 2006 10:48
Wohnort: DE Freiburg

Diagonale distanz von QRect

Beitrag von patrik08 »

Wie bekomme ich die diagonale von eine QRect?
Bin mit mathematik etwas kalt geworden...

es geht ja nur um eine bilder drehung....

Code: Alles auswählen


void EditorPics::setRotate( const int r )
{
	if (LastAngleRotate == r) {
		return;
	}
	NopermissionReselection = true;
	LastAngleRotate = r;
	rubberBand->hide();
	Selection = QRect(0,0,0,0);  /* QRubberBand go NULL novalid */
     if (r < 360) {
								QPixmap rotate_pic = QPixmap(OriginalCopypic);
                int massimo = qMax(rotate_pic.width(),rotate_pic.height());    /* find  max cube from image diagonale  */
                int fotox = (massimo / 2) - (rotate_pic.width() / 2);
                int fotoy = (massimo / 2) - (rotate_pic.height() / 2);
                QPixmap nuovo(massimo,massimo);
			          nuovo.fill( Qt::transparent );
                QPainter painter;
                painter.begin(&nuovo); 
                painter.setRenderHint(QPainter::Antialiasing);
                painter.translate((massimo / 2),(massimo / 2));
                painter.rotate(r); 
                painter.translate(-(massimo / 2),-(massimo / 2));
                painter.drawPixmap(fotox,fotoy,rotate_pic);
                painter.end();  
			          pic = nuovo;   /* new image */
			          update();
					      setMinimumSize(sizeHint());
	              setMaximumSize(sizeHint());
			          LastAngleRotate = r;
     }
}
.........................
speack português italiano deutsch english castellà qt
patrik08
Beiträge: 746
Registriert: 27. Februar 2006 10:48
Wohnort: DE Freiburg

Beitrag von patrik08 »

Super geloest ohne zu rechnen...

Code: Alles auswählen


static inline qreal Diagonale( const QRect Master )
{
  QLineF VirtualLine(Master.topLeft(),Master.bottomRight());
  return VirtualLine.length();
}

.........................
speack português italiano deutsch english castellà qt
Antworten