Hi all, I am trying to paint with QLabel derived widget and still get widgets frame to be visible. When there is a frame without a drawing function, the frame is shown correctly. The problem is that when I reimplement paintEvent method, the frame is not shown anymore.


Qt Code:
  1. class GameArea: public QLabel {
  2. public:
  3. GameArea(QWidget *parent = 0);
  4. ~GameArea();
  5.  
  6. protected:
  7. void paintEvent(QPaintEvent *event);
  8. };
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. label = new GameArea(Exercise2Class);
  2. label->setFrameShape(QFrame::StyledPanel);
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. void GameArea::paintEvent(QPaintEvent * /* event */)
  2. {
  3. QPainter painter(this);
  4. QPen pen;
  5. QBrush brush;
  6. pen.setColor(Qt::red);
  7. brush.setStyle(Qt::SolidPattern);
  8. brush.setColor(Qt::red);
  9. painter.setPen(pen);
  10. painter.setBrush(brush);
  11. painter.drawEllipse(rect().center(), 20, 20);
  12. }
To copy to clipboard, switch view to plain text mode