在 Qt 中旋转图像 [英] Rotate Image in Qt

查看:38
本文介绍了在 Qt 中旋转图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我想旋转图像(我在 QLabel 上设置了图像).我已经设置了一个 QPushButton,点击那个按钮我想在四个方向上旋转我的图像(右->底部->左->顶部)

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)

有什么帮助吗?

推荐答案

假设你有一个指向 QLabel 的指针,你可以做类似的事情

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.

这篇关于在 Qt 中旋转图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆