setPos() doesn't use parent coordinates

1k views Asked by At

Here is part of the code, when sending x=0 and y=0, it places the child item "text" in the (0,0) of the scene not relative to its parent !

void ClassA::putLabel(qreal x, qreal y, QString text, QGraphicsPolygonItem* parent) {

    QGraphicsTextItem * io = new QGraphicsTextItem;
    io->setParentItem(parent);
    io->setPos(x, y);
    io->setFlags(QGraphicsItem::ItemIgnoresTransformations);
    //io->setHtml("<div style='font-size: 10px; padding: -2px; margin: -2px;'>" + text + "</div>");
    io->setFont(QFont("Helvetica", 8));
    io->setPlainText(text);
}
0

There are 0 answers