【问题标题】:Qt: Rotating a label with a Pixmap on itQt:旋转带有像素图的标签
【发布时间】:2015-11-20 15:31:51
【问题描述】:

我有一个带有像素图的标签 代码如下所示:

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)

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

【问题讨论】:

    标签: qt label rotation pixmap


    【解决方案1】:

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

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

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

    【讨论】:

      【解决方案2】:

      查看QMatrix 中的示例。

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

      【讨论】:

        猜你喜欢
        • 2011-01-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-01-21
        • 1970-01-01
        • 2014-12-29
        相关资源
        最近更新 更多