Rendering a QGraphicsTextItem with ObjectReplacementCharacter
-
Hello.
I have a QGraphicScene with a QGraphicsTextItem. This text item contains some normal text, and an ObjectReplacementCharacter with a QTextImageFormat that displays an image in the text. Everything works fine when the scene renders the item, but now I want to drag the item, and for that I'd like to render it to a QPixmap. I call QGraphicsTextItem::paint() manually, with a painter that draws on the QPixmap. The normal text renders correctly, but the image is not visible.
My code looks like this
@
QPixmap pixmap(/* size of the item */);
pixmap.fill(QColor(0,0,0,0));
QPainter painter(&pixmap);
QStyleOptionGraphicsItem styleOptions;
styleOptions.rect = pixmap.rect();
styleOptions.exposedRect = pixmap.rect();
styleOptions.direction = view()->viewport()->layoutDirection();
paint(&painter, &styleOptions, view()->viewport());
@view() returns the QGraphicsView I am using. This code works for QGraphicsTextItems with normal text, and for custom items that draw Images (with QPainter::drawImage()). But it seems to ignore images included in QGraphicsTextItems via a ObjectReplacementCharacter.
Can anybody think of a reason for that?