#ifndef ROLLSWITCHWIDGET_H #define ROLLSWITCHWIDGET_H #include class RollSwitchWidget : public QWidget { Q_OBJECT public: explicit RollSwitchWidget(QWidget *parent = nullptr); void setCount(int count); int currentIndex(); Q_SIGNALS: void indexChange(int index); protected: void paintEvent(QPaintEvent *e) override; void mousePressEvent(QMouseEvent*e) override; private: QPointF getPoint(const QRect &rect, int angle); private: QString m_text; QRect m_leftRect; QRect m_rightRect; int m_index; int m_count; }; #endif // ROLLSWITCHWIDGET_H