I think this is what you want
Qt Code:
  1. class ArcWidget : public QWidget
  2. {
  3. protected:
  4. void paintEvent(QPaintEvent * event) override
  5. {
  6. QPainter painter(this);
  7.  
  8. const double radius = qSqrt(qPow(width()/2.0, 2) + qPow(height()/2.0, 2));
  9. const int startAngle = qAtan((width()/2.0)/radius) * 180 / M_PI * 16;
  10. const int spanAngle = (90 - startAngle) * 2 * 16;
  11. const QRect rect = event->rect().adjusted(-(radius-width()/2.0), height()-radius, (radius-width()/2.0), radius);
  12.  
  13. painter.drawArc(rect, startAngle, spanAngle);
  14. }
  15. };
  16.  
  17. int main(int argc, char *argv[])
  18. {
  19. QApplication app(argc, argv);
  20.  
  21. ArcWidget widget;
  22. widget.show();
  23.  
  24. return app.exec();
  25. }
To copy to clipboard, switch view to plain text mode