[Interest] I know I'm just being stupid here...
Bob Hood
bhood2 at comcast.net
Fri Jan 25 00:44:41 CET 2019
Thanks, Jason. That wasn't the exact issue, but it made me realize that the
settings in Qt Designer were clipping it. Reversing the width/height values of
the label there got it working.
On 1/24/2019 10:00 AM, Jason H wrote:
> update: boundingRect() applies to QGraphicsItems, for regular QWidgets, you
> want size() or sizeHint() (note they are marked virtual)
> *Sent:* Thursday, January 24, 2019 at 11:53 AM
> *From:* "Jason H" <jhihn at gmx.com>
> *To:* "Bob Hood" <bhood2 at comcast.net>
> *Cc:* interest at qt-project.org
> *Subject:* Re: [Interest] I know I'm just being stupid here...
> It's been a while, but I think you need to provide a boundingRect()
> implementation that reflects the transformed size.
> *Sent:* Wednesday, January 23, 2019 at 10:18 PM
> *From:* "Bob Hood" <bhood2 at comcast.net>
> *To:* interest at qt-project.org
> *Subject:* [Interest] I know I'm just being stupid here...
> 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.
>
> _______________________________________________ Interest mailing list
> Interest at qt-project.org https://lists.qt-project.org/listinfo/interest
> _______________________________________________ Interest mailing list
> Interest at qt-project.org https://lists.qt-project.org/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190124/9bc3f7ca/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hmcdaanfdpainpjp.png
Type: image/png
Size: 55992 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190124/9bc3f7ca/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fakljjnjceogkoie.png
Type: image/png
Size: 57496 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190124/9bc3f7ca/attachment-0001.png>
More information about the Interest
mailing list