Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Rotate Image in Qlable

Rotate Image in Qlable

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 3.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Techatieas
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      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);
      }

      1 Reply Last reply
      3

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved