Change drawARC starting position



  • 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)!



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



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



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


Log in to reply
 

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