Qt:旋转带有像素图的标签

发布于 2024-11-17 18:25:08 字数 496 浏览 7 评论 0原文

我有一个带有像素图的标签 代码看起来像这样:

Label = new QLabel (dialog, Qt::Widget);
Label -> setGeometry( xPosition, yPosition, 25, 87 );
QPixmap pixmap;
pixmap.load("/home/richter/Dokumente/QDevelop/AnimationTest/ScreenData/rightTire.png", 0, Qt::DiffuseAlphaDither);
Label -> setPixmap(pixmap);
Label -> setAlignment(Qt::AlignCenter);
Label -> show();

我现在想要的是这样的方法:

void rotateLabel (int degrees)

我认为它应该做什么很清楚。您输入度数并看到它旋转了这些度数。

I have a label with a pixmap on it
Code looks like this:

Label = new QLabel (dialog, Qt::Widget);
Label -> setGeometry( xPosition, yPosition, 25, 87 );
QPixmap pixmap;
pixmap.load("/home/richter/Dokumente/QDevelop/AnimationTest/ScreenData/rightTire.png", 0, Qt::DiffuseAlphaDither);
Label -> setPixmap(pixmap);
Label -> setAlignment(Qt::AlignCenter);
Label -> show();

what I now want to have is a method like that:

void rotateLabel (int degrees)

I think it's clear what it should do. You enter the degrees and see it rotated by these degrees.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

白龙吟 2024-11-24 18:25:08

运行qtdemo ->示范->嵌入式对话框

它展示了如何将整个对话框映射到 3D 表面。同样的技术允许您旋转单个标签。

源代码在这里: http://doc.qt.io/archives/ qt-4.7/demos-embeddeddialogs.html

Run qtdemo -> Demonstrations -> Embedded Dialogs

It shows how to map a whole dialog to a 3D surface. The same technique allows you to rotate a single label.

Source code is here: http://doc.qt.io/archives/qt-4.7/demos-embeddeddialogs.html

沩ん囻菔务 2024-11-24 18:25:08

查看 QMatrix 中的示例。

您需要覆盖 QLabel 的绘制事件并与给定示例类似地进行绘制。

Checkout the examples in QMatrix.

You need to override paint event of your QLabel and draw similar to given example.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文