#pragma once #include #include #include class TestView : public QDialog { Q_OBJECT public: TestView(QWidget* parent = nullptr) : QDialog(parent) {} ~TestView() {} void paintEvent(QPaintEvent* event) { QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing, true); painter.setRenderHint(QPainter::SmoothPixmapTransform, true); qreal radius = 200 * 10000.0f; auto _paint = [&](double x, double yAdjust, const QString& color) { QPointF center{ x, radius + yAdjust }; painter.setPen(QColor(color)); painter.drawArc(QRectF{ center.x() - radius, center.y() - radius, radius * 2.0f, radius * 2.0f }, 85.0f * 16.0f, 10.0f * 16.0f); for (int ii = 0; ii < width(); ii += 10) { double x = ii; double r2 = radius * radius; double y = std::sqrt(r2 - std::pow(center.x() - x, 2)); double y1 = center.y() + y; double y2 = center.y() - y; painter.drawEllipse(QPointF{ x, y1 }, 2.0f, 2.0f); painter.drawEllipse(QPointF{ x, y2 }, 2.0f, 2.0f); } }; _paint(-40000, -350, "#FF0000"); _paint(0, 200, "#00FF00"); _paint(40000, 0, "#0000FF"); } };