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. Change drawARC starting position
Forum Updated to NodeBB v4.3 + New Features

Change drawARC starting position

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.1k 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.
  • R Offline
    R Offline
    rcourtney
    wrote on last edited by
    #1

    I am making an audio control package and am having trouble figuring out
    the coordinate system.

    Is there a way to rotate the start of the arc from the 3 o'clock position
    to 7 o'clock to reflect modern audio dials?

    @void MainWindow::displayARC(int angle)
    {
    QPixmap pix(61,61);
    QPen pen;
    pix.fill(Qt::transparent);
    QPainter painter(&pix);
    painter.setRenderHint(QPainter::Antialiasing);
    pen.setWidth(3);
    pen.setColor(QColor(220,220,0,255));
    painter.setPen(pen);
    painter.drawArc(11, 11, 38, 38, 0,
    (int) angle * -16);
    ui->labelARC->setPixmap(pix);
    }@

    example:
    !http://cdn-data.motu.com/site/images/news/mk3-eq-tab.png(example:)!

    image for code snipit:
    !https://dl.dropboxusercontent.com/u/83007019/file_407.png(dial)!

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      Did you get a chance to look at QTransform class ? It may help you.@@

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rcourtney
        wrote on last edited by
        #3

        My inability to comprehend the coordinate system is my biggest hurdle.
        I will review the transform class. Thanks.

        !https://dl.dropboxusercontent.com/u/83007019/TestDials.PNG!

        @void MainWindow::displayMark(qreal angle)
        {
        QPixmap pix(61,61);
        QPen pen;
        pen.setWidth(3);
        pen.setColor(QColor ( 22,22,255,255 ));
        pix.fill(Qt::transparent);
        QPainter painter(&pix);
        painter.translate(pix.width()/2.0,pix.height()/2.0);
        painter.rotate(angle +130.0); // Zero is 3:00 position
        painter.setPen(pen);
        painter.setRenderHint(QPainter::Antialiasing);
        painter.drawLine(23.5, 0.0, 3.0, 0.0);
        ui->label->setPixmap(pix);
        }@

        1 Reply Last reply
        0
        • R Offline
          R Offline
          rcourtney
          wrote on last edited by
          #4

          Finally figured it out. Order is important.

          @void MainWindow::displayARC(int angle)
          {
          QPixmap pix(61,61);
          pix.fill(Qt::transparent);
          QPen pen;
          pen.setWidth(3);
          pen.setColor(QColor(220,220,0,255));
          pix.fill(Qt::transparent);
          QPainter painter(&pix);
          painter.setRenderHint(QPainter::Antialiasing);
          painter.translate(pix.width()/2.0,pix.height()/2.0);
          painter.rotate(130.0); // Zero is 3:00 position
          painter.setPen(pen);
          painter.drawArc(-19, -19, 38, 38, 0,(int)angle * -16);
          ui->labelARC->setPixmap(pix);
          }

          void MainWindow::displayMark(qreal angle)
          {
          QPixmap pix(61,61);
          pix.fill(Qt::transparent);
          QPen pen;
          pen.setWidth(3);
          pen.setColor(QColor(22,22,255,255));
          QPainter painter(&pix);
          painter.setRenderHint(QPainter::Antialiasing);
          painter.translate(pix.width()/2.0,pix.height()/2.0);
          painter.rotate(angle +130.0); // Zero is 3:00 position
          painter.setPen(pen);
          painter.drawLine(23.5, 0.0, 3.0, 0.0);
          painter.drawArc(-19, -19, 38, 38, 0,(int)angle * 16);
          ui->label->setPixmap(pix);
          }
          @

          1 Reply Last reply
          0

          • Login

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