QLabel旋转 [英] QLabel rotation

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

问题描述

我有一个像素图的标签设置如下:

I am having a label set from a pixmap as follow:

QLabel* label_image;
label_image= new QLabel (this);
label_image->setGeometry(0, 0, 500, 30);

QPixmap pm;
pm ...
label_image->setPixmap(pm);

我现在想旋转90度。如何这样做?

I would like now to rotate it by 90 degrees. How to do so?

推荐答案

这里有两个选项。第一个是子类化QLabel并提供所需的旋转功能。或者,您可以使用QTransform旋转您在QLabel上设置的QPixmap。

You have two options here. The first is to subclass QLabel and provide the rotation functionality that you require. Alternatively, you can use QTransform to rotate the QPixmap that you set on the QLabel.

而不是反复回答,此链接说明如何进行旋转并保持图像的原始大小。

Rather than regurgitating the answer, this link explains how to do the rotation and maintain the original size of the image.

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

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