Hi,
I have a QGraphicsScene with a QGraphicsTextItem and a QGraphicsRectItem as child of the text item.
What I want is the text item to be displayed on top of the rect item and move the rect item when the text is moved.
The problem is that the rect item is always displayed on top of the text item. The only way to display the text on top of the rect item is to not set the text item as parent of the text rect(then the two items are independents and this is not what I want).
Am I missing something?
Qt Code:
ui.graphicsView->setScene(pqScene); pqText->setPlainText("Hello"); //QGraphicsTextItem *pqText = pqScene->addText("Hello"); //Tried this with same result pqText->setZValue(0); //QGraphicsRectItem *pqRect = pqScene->addRect(pqText->boundingRect()); //Tried this with same result //pqRect->setParentItem(pqText); pqRect->setBrush(Qt::red); pqRect->setZValue(-1); pqRect->setRect(pqText->boundingRect()); pqScene->addItem(pqText); pqScene->addItem(pqRect);To copy to clipboard, switch view to plain text mode
Using Qt 5.4.1 on Windows with Visual Studio 2013.
Thanks,
Bookmarks