开发者

Qt: Rotating a label with a Pixmap on it

开发者 https://www.devze.com 2023-03-16 08:46 出处:网络
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 );

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 -> se开发者_如何学PythontAlignment(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.


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


Checkout the examples in QMatrix.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消