Rotate an QLabel
-
Hi,
Or you can use QImage::transformed passing it a rotation matrix.
-
Okey I found a solution for me
QPixmap pixmap(*ui->label->pixmap()); QMatrix rm; rm.rotate(50); pixmap = pixmap.transformed(rm); ui->label->setPixmap(pixmap);
but the problem ist now, Im trying to draw the pixmap every time at the different rotate which was saved at mine vector. what is happening, it´s just rotate further
-
@CptN3m0
Well the normal solution is to keep the original unrotated bitmap and
assign a copy to the label. Then when new rotate is need , the original image is used
and not the already rotated version.You can also rotate it back, and rotate to a new angle but that often
distorts the image slowly. -
Hi,
Where does your QPixmap come from in the first place ?
-
@CptN3m0
Wait i just realized. you are just doing it to rotate text right ?
Not the actual image ?
So only the text matters. so u can just clear it and redraw text.QPixmap pixmap(*ui->label->pixmap());
pixmap.fill( Qr::red ); // just clear old
QMatrix rm;
rm.rotate(50);
pixmap = pixmap.transformed(rm);
...drawtext..
ui->label->setPixmap(pixmap);