QGraphicsTextItem - paint and html
-
Hi there,
I have subclassed QGraphicsTextItem and I want to put a semi transparent box behind the HTML formatted text. But doing the following, in the paint routine, doesn't work:
painter->fillRect(boundingRect(),brush); QGraphicsTextItem::paint(painter,option,widget);
If I use plainText, there is no problem drawing a rectangle behind the text. But when I use setHTML, the box is not drawn. Am I missing something or is this something that can't be done in a subclassed QGraphicsTextItem? Any pointers would be appreciated.
Best wishes (and seasons greetings)
Ziggx -
Hi
Can it be something in the HTML ?
If i use the Diagram example and use setHTML its still transparent.auto html = R"( <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html> <head> <meta name="qrichtext" content="1" /> <style type="text/css"> p, li { white-space: pre-wrap; } </style> </head> <body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">This</span> is <span style=" font-size:14pt; font-weight:600;">HTML</span><span style=" font-style:italic;">text</span></p> </body> </html> )"; DiagramTextItem* item = qgraphicsitem_cast<DiagramTextItem*>(selectedItems().first()); item->setHtml(html) ;
-
@ziggx
Super.
I often suggest that sample if people want to make any kind of diagram editor as its a good start.
Yeah, every now and then our local Qt Lord suggests some class i never saw before :)Merry Christmas and a glorious new year