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.

  • Lifetime Qt Champion

    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.

    Anyway, you should be able do something like
    (pseudo code)

    void MainWindow::rotateLabel()
    QPixmap pixmap( needlepixmap );
    QMatrix rm;
    pixmap = pixmap.transformed(rm);

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.