Question

Is there a way of inserting an image in a QString? I need to have a QString this way " 'image' some text"

It needs to be a QString since i'm inserting it in a QPaint event and i cant use a QLabel for that (because i can't insert a qlabel into the painting area)

Thanks for all the help!

Was it helpful?

Solution

QString only contain and display text. If you want do do such a thing, you can write rich text in your QString (with HTML syntax) and display it in a component with is able to display rich text (here QGraphicsTextItem because you seem to work in a scene) :

QString myRichText = "<img src=\"URL or URI of the image\"/> some text";
QGraphicsTextItem textDisplayer(myRichText);
// Hack, hack, hack in your scene
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top