class MyWidget : public QWidget{ Q_OBJECTpublic: MyWidget(QWidget* parent = 0) : QWidget(parent), m_drawRect(false), m_drawCircle(false) { }public slots: void drawRect() { m_drawRect = true; update(); } void drawCircle() { m_drawCircle = true; update(); }protected: void paintEvent(QPaintEvent* event) { Q_UNUSED(event); QPainter painter(this); painter.setPen(Qt::darkGray); painter.setBrush(Qt::darkGray); if(m_drawRect) painter.drawEllipse(rect()); if(m_drawCircle) painter.drawEllipse(rect()); }private: bool m_drawRect; bool m_drawCircle;};