Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rotate Image in Qt

In my application I want to rotate image (I have set image on QLabel). I have set one QPushButton, on click that button I want to rotate my image in Four directions (Right->Bottom->Left->Top)

Any help?

like image 333
Piyush Avatar asked Jan 12 '11 05:01

Piyush


1 Answers

Assuming you have a pointer to your QLabel you could do something like

void MyWidget::rotateLabel()
{
    QPixmap pixmap(*my_label->pixmap());
    QMatrix rm;
    rm.rotate(90);
    pixmap = pixmap.transformed(rm);
    my_label->setPixmap(pixmap);
}

This will take you through Right, Bottom, Left, Top in four applications.

like image 200
dabhaid Avatar answered Dec 18 '22 09:12

dabhaid