I'm having a QT/C++ problem with a simple QWidget program that draws an ellipse inside a child QWidget.
The program is composed of:
(1) A parent QWidget
(2) A child QWidget (used as the drawing surface for an ellipse)
(3) A draw QPushButton
Here is part of the code (QPushButton Slot and Signal code omitted for simplicity)
void Draw::paintEvent(QPaintEvent *event) {
QPainter painter;
painter.begin(child_Widget); //The line with the problem
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen(Qt::black, 12, Qt::DashDotLine, Qt::RoundCap));
painter.setBrush(QBrush(Qt::green, Qt::SolidPattern));
painter.drawEllipse(50, 50, 100, 100);
painter.end();}
Line 2 painter.begin(child_Widget); doesn't do anything. The program draws the ellipse only if I replace line 2 with painter.begin(this); but that draws on the parent QWidget and not on the child QWidget as desired.
p.s. I have the child_Widget housed inside a GroupBox which in turn is housed inside a QVBoxLayout Any Suggestion?
Thanks.