示例#1
0
void PaintCanvas::repaint(Graphics &gc) {
  // Clear the canvas to white.
  gc->set_source_rgb( 1.0, 1.0, 1.0 );
  gc->paint();

  // Iterate over the stored shapes and ask them to draw themselves.
  for( list<PaintShape*>::iterator i = m_shapes.begin(); 
      i != m_shapes.end(); ++i ) {
    PaintShape *shape = (*i);
    shape->draw( gc );
  }
}
示例#2
0
void PaintCanvas::paintEvent(QPaintEvent * event) {
    QPainter painter(this);
    // painter.setPen(palette().dark().color());
    painter.setRenderHint(QPainter::Antialiasing, true);

    // Iterate over the stored shapes and ask them to draw themselves.
    for( list<PaintShape*>::iterator i = m_shapes.begin(); 
            i != m_shapes.end(); ++i ) {
        PaintShape *shape = (*i);
        shape->draw( painter );
    }

    painter.setRenderHint(QPainter::Antialiasing, false);
    painter.drawRect(QRect(0, 0, width() - 1, height() - 1));
}