[Qt-interest] Emulating selection with offsets
sathya tej
ragesathya at gmail.com
Tue Apr 21 18:31:33 CEST 2009
Dear all,
As per Stephen's advice i wrote the following code...
QTextDocument *document =
textEditorArray[textEditorCount]->document();
QTextCursor *cur = new QTextCursor(document);
QTextCursor *cur1 = new QTextCursor(document);
QTextCharFormat plainFormat(cur->charFormat());
QTextCharFormat colorFormat = plainFormat;
colorFormat.setForeground(Qt::red);
cur1->beginEditBlock();
cur->setPosition(startOffset);
cur->setPosition(endOffset,QTextCursor::KeepAnchor);
cur->mergeCharFormat(colorFormat);
Problem i am facing is that, the section of code which i wanted to be
highlighted in red color, is now not appearing at all.
All those sections are now blank.
I am using Qt 4.3.4 and ubuntu 8.04.
Please help me.
Thank You.
Sathya.
On Tue, Apr 21, 2009 at 7:38 PM, John McClurkin <jwm at nei.nih.gov> wrote:
> sathya tej wrote:
> >
> > Please help me out guys, I am in deep trouble.
> >
> > Thank You.
> >
> > Sathya.
> Have you looked at the textedit demo or the richtext example in the Qt
> distribution?
>
> >
> >
> > On Tue, Apr 21, 2009 at 7:17 AM, sathya tej <ragesathya at gmail.com
> > <mailto:ragesathya at gmail.com>> wrote:
> >
> >
> > Hello all,
> >
> > I have a text file. I only have startOffset and endOffset of a
> > section of text in that file.
> >
> > I need to highlight that section.
> >
> > I used the below approach but failed.
> >
> > Please guide me.
> >
> >
> >
> > QTextCursor *cur = new QTextCursor();
> >
> > textEditorArray[textEditorCount]->setTextCursor(*cur);
> >
> > cursor->setPosition (startOffset , QTextCursor::MoveAnchor );
> >
> > cursor->movePosition ( QTextCursor::NextCharacter,
> > QTextCursor::KeepAnchor, endOffset - startOffset);
> >
> > textEditorArray[textEditorCount]->setFontUnderline(true);
> >
> >
> >
> >
> >
> > --
> > whatever happens happens for GOOD
> >
> >
> >
> >
> > --
> > whatever happens happens for GOOD
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
--
whatever happens happens for GOOD
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090421/2902aec8/attachment.html
More information about the Qt-interest-old
mailing list