Not sure what exactly what you want to do, anyway here is an example to use QPainterPath.
Qt Code:
  1. class MyWidget : public QWidget
  2. {
  3. public:
  4. explicit MyWidget(QWidget * parent = 0)
  5. : QWidget(parent) { }
  6.  
  7. protected:
  8. void paintEvent(QPaintEvent * event)
  9. {
  10. QPainter painter(this);
  11.  
  12.  
  13. const QRect rect = event->rect();
  14. const QPoint center = rect.center();
  15. const int height = rect.height() / 4;
  16. const int width = rect.width() / 4;
  17.  
  18. path.moveTo(center);
  19. path.moveTo(center.x() , center.y() - height);
  20. path.lineTo(center.x() + width , center.y() - height);
  21. path.lineTo(center.x() + width , center.y());
  22. path.lineTo(center.x() + width , center.y() + height);
  23. path.closeSubpath();
  24.  
  25. painter.setPen(QPen(QBrush(Qt::red), 5));
  26. painter.drawPath(path);
  27. painter.fillPath(path, QBrush(Qt::CrossPattern));
  28. }
  29. };
  30.  
  31. int main(int argc, char *argv[])
  32. {
  33. QApplication app(argc, argv);
  34.  
  35. MyWidget widget;
  36. widget.show();
  37.  
  38. return app.exec();
  39. }
To copy to clipboard, switch view to plain text mode