[Interest] Non-square QGraphicsTextItem

Simon Gemmell gemmell101 at hotmail.com
Fri Feb 17 12:29:48 CET 2012


Hi,

I've been wondering if anyone has ever seen QGraphicsTextItem's that aren't square. I essentially want to be able to chain up these non square QGraphicsTextItems to do something like this:   |Hi this is some text andit is not square||This is somemore text also not square|
I know I can create my own oddly shaped graphics items and use the QTextLayout to lay the text out in them, but I still then need to re-implement all the stuff to be able to edit the text. I assume that it's quite onerous to implement all the text editing features - there's certainly a lot of Qt code to do it. Would be happy if someone says that making it editable isn't really that hard... I'm looking for the shove in the right direction.
So the only way I've come up with to make the QGraphicsTextItem not square in my head involves a little hackery: use textIndent to shift the first line in, and hack an extra function into the Qt source which will tell me how long the last line is. This will mean I can "chain them up". I would also have to override shape() so that clicking gets picked up by the right element. Would this work? Or is it better just to implement my own graphics item with text editing features?
Regards,SimonPS. The QTextDocument/QTextEdit is just not flexible enough for me to use for my purpose. I've done it to death (I think). Be happy to be wrong. Too hard to keep my model in sync with the text. I don't get enough control over what happens when things get edited in the text. 		 	   		  

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120217/1cc595d8/attachment.html>


More information about the Interest mailing list