[Interest] I know I'm just being stupid here...

Bob Hood bhood2 at comcast.net
Thu Jan 24 04:18:56 CET 2019


I'm trying to render rotated rich text, and it just keeps clipping on me.  I 
can't seem to find the magic combination that will expand the clipping region.

The simplest paintEvent():

    void VerticalLabel::paintEvent(QPaintEvent*)
    {
         QPainter painter(this);

         painter.rotate(-20);

         QTextDocument td;
         td.setHtml(text());
         td.drawContents(&painter);
    }

Slightly more involved paintEvent():

    void VerticalLabel::paintEvent(QPaintEvent*)
    {
         QPainter painter(this);

         painter.rotate(-20);

         QTextDocument td;
         td.setHtml(text());
         QAbstractTextDocumentLayout::PaintContext ctx;
         ctx.clip = QRectF(0, 0, 100, 400);
         td.documentLayout()->draw(&painter, ctx);
    }

In both cases, I'm going from this without the rotation:



to this with it:




Question:  How do I alter this clipping so the text is visible when it is 
vertical?  Setting the PaintContext.clip doesn't appear to have any impact no 
matter what values I put in it, and Google doesn't have any answers, as far as 
I could find.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190123/26385667/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2019-01-23_20-13-25.png
Type: image/png
Size: 55992 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190123/26385667/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2019-01-23_20-14-28.png
Type: image/png
Size: 57496 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190123/26385667/attachment-0001.png>


More information about the Interest mailing list