[Interest] I know I'm just being stupid here...
Tony Rietwyk
tony at rightsoft.com.au
Thu Jan 24 18:22:00 CET 2019
This is what I do in a model delegate to paint html in cell:
QAbstractTextDocumentLayout::PaintContext ctx;
ctx.palette = optionV4.palette;
// Elided code to change the ctx.palette depending on the cell state
QTextDocument doc;
doc.setDefaultFont(optionV4.font);
doc.setTextWidth(textRect.width());
doc.setDocumentMargin( mTextMargin );
doc.setHtml(savedText);
painter->save();
painter->translate(textRect.topLeft());
painter->setClipRect(textRect.translated(-textRect.topLeft()));
doc.documentLayout()->draw(painter, ctx);
painter->restore();
Note that I'm using painter->setClipRect.
Regards, Tony
On 25/01/2019 3:44 am, Bob Hood wrote:
> Thanks for the response, Tony.
>
> I added an explicit setting of the page size:
>
> ...
> QTextDocument td;
> QSizeF size(2000, 2000);
> td.setPageSize(size);
> td.drawContents(&painter);
> ...
>
> Unfortunately, I still get the same clipping region as before.
>
>
> On 1/23/2019 8:49 PM, Tony Rietwyk wrote:
>>
>> Hi Bob,
>>
>> I think you'll need to increase the size of the document - maybe the
>> paintContext is being clipped to the document size?
>>
>> Hope that helps,
>>
>> Tony
>>
>>
>> On 24/01/2019 2:18 pm, Bob Hood wrote:
>>> 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/20190125/b5556000/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/20190125/b5556000/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/20190125/b5556000/attachment-0001.png>
More information about the Interest
mailing list