Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Rendering a QGraphicsTextItem with ObjectReplacementCharacter

Rendering a QGraphicsTextItem with ObjectReplacementCharacter

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mkuettler
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved