PDA

View Full Version : Drawing a custom QGraphicsItem



saifulkhan
12th March 2013, 17:26
Dear QtCummunity,

I would like to draw a custom item like the attached image. Request your suggestion please.



void MyItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
// Please suggest me

}

d_stranz
12th March 2013, 20:09
Use QPainter::drawLine(), QPainter::drawRect(), and QPainter::drawPolygon() (for the triangle). Use whatever dimensions are the most convenient for your application, since all of the transformations to set position, scale, and rotation are done by the parent of your MyItem.

Santosh Reddy
12th March 2013, 20:09
Do you want to paint it as a single item? then use QPainterPath(s)

You could also use multiple QGrpahicsLineItems, and use QPen and QBrush settings as needed.