[Interest] Highlighting selected text in QTextDocument::drawContents()

igor.mironchik at gmail.com igor.mironchik at gmail.com
Tue Apr 1 12:11:45 CEST 2014


Don't know will it work with QTextDocument::drawContents() or not.

I did it like it done in QTextEdit:

p.save();
QAbstractTextDocumentLayout::PaintContext ctx = getPaintContext( q );
p.setClipRect( r, Qt::IntersectClip );
ctx.clip = r;

doc->documentLayout()->draw( &p, ctx );
p.restore();

-----Original Message----- 
From: Diego Iastrubni
Sent: Tuesday, April 01, 2014 10:41 AM
To: igor.mironchik at gmail.com
Cc: interest at qt-project.org
Subject: Re: [Interest] Highlighting selected text in 
QTextDocument::drawContents()

Depends on the use case, but what about
QTextDocument::setExtraSelections() with the correct QTextCursor?

See:
http://qt-project.org/doc/qt-4.8/qtextedit.html#setExtraSelections

On Sat, Mar 29, 2014 at 10:27 PM,  <igor.mironchik at gmail.com> wrote:
> Hi.
>
> How to highlight selected text in QTextDocument::drawContents() ?
>
> Thanks.
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
> 




More information about the Interest mailing list