Using Pen and Brush to draw : QBrush « Qt « C++






Using Pen and Brush to draw

  


#include <QtGui>

int main(int argc, char* argv[])
{
  QApplication app(argc, argv);
  QRect r(0,0, 100, 100);
  QPixmap pm(r.size());
  pm.fill();

  QPainter p(&pm);
  p.setRenderHint(QPainter::Antialiasing, true);
  QPen pen(Qt::red, 2);
  p.setPen(pen);
  QBrush brush(Qt::blue);
  p.setBrush(brush);
  QRect ri = r.adjusted(10,10,-10,-10)
  p.drawEllipse(ri);
  QLabel l;
  l.setPixmap(pm);

  l.show();
  return app.exec();
}

   
    
  








Related examples in the same category

1.Paint with QBrush
2.Basic drawing
3.Create brush
4.Set push button checkable to true