Reputation: 2609
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?
Upvotes: 9
Views: 26333
Reputation: 175
QMatrix is deprecated so you can use QTransform instead
void MyWidget::rotateLabel()
{
QPixmap pixmap(*my_label->pixmap());
QTransform tr;
tr.rotate(90);
pixmap = pixmap.transformed(tr);
my_label->setPixmap(pixmap);
}
Upvotes: 6
Reputation: 3879
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.
Upvotes: 21