Qt:旋转带有像素图的标签
我有一个带有像素图的标签 代码看起来像这样:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
运行
qtdemo
->示范->嵌入式对话框它展示了如何将整个对话框映射到 3D 表面。同样的技术允许您旋转单个标签。
源代码在这里: http://doc.qt.io/archives/ qt-4.7/demos-embeddeddialogs.html
Run
qtdemo
-> Demonstrations -> Embedded DialogsIt 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
查看 QMatrix 中的示例。
您需要覆盖 QLabel 的绘制事件并与给定示例类似地进行绘制。
Checkout the examples in QMatrix.
You need to override paint event of your QLabel and draw similar to given example.