I haven’t found an exact question on this.
I have a picture, it could be blank for the sake of the example, or contain something that I want to add a fancy caption to. I want to add text editing means (akin to Photoshop) on top of the picture.
I’m thinking about subclassing QGraphicsScene and placing a subclassed QTextEdit object on the scene upon pressing a text placement button. Then, when you click on this object, in addition to editing the text, additional text editing tools become available – so you can set parts of text to bold, italic, modify color, size, etc. And then you would be able to change the object’s position – and I think that’s available in QGraphicsScene by default. And for the background QBrush, there would be a background picture.
Is this a reasonable solution?
Maybe there are any ready-available examples of this, but I haven’t found them yet.
My solution
Text item:
For the text item, I used
QGraphicsScenewith a subclassedQGraphicsTextItem. For the background picture, I used aQGraphicsRectItemwith aQBrushand a loaded picture usingQImagemethods.To edit parts of the selected text in this subclassed QGraphicsTextItem:
QTextCharFormatapplied to my subclassedQGraphicsTextItemusingQGraphicsTextItem::textCursor().mergeCharFormat(...). This way I can change formatting, such as boldness, italics, etc. on the selection only.Some more thingies:
To pan and zoom around the scene, I used an excellent guide by Vpicaver complete with source code from http://www.qtcentre.org/wiki/index.php?title=QGraphicsView:_Smooth_Panning_and_Zooming