Rotate Image in Qlable
-
I want to make speedometer application in Qt CPP. My idea is set background circle image in Qframe. In Qframe put one label and set needle image on Qlabel and rotate needle 0 to 360 degree.
My query is how to rotate? Can i rotate Qlabel or image? How?
Please help me. -
Hi
You should create a subclass of QWidget and make a paintevent
Here you first draw the circle image and then use QPainter
to draw rotated Needle.
That will work better than rotating a label.The clock sample can be inspiration.
http://doc.qt.io/qt-5/qtwidgets-widgets-analogclock-example.html
Anyway, you should be able do something like
(pseudo code)void MainWindow::rotateLabel()
{
QPixmap pixmap( needlepixmap );
QMatrix rm;
rm.rotate(90);
pixmap = pixmap.transformed(rm);
ui->my_label->setPixmap(pixmap);
}