For multiple selections, you might have to go with a function.
In Q3TextEdit, you can find a protected function:
void Q3TextEdit::setSelection(int paraFrom, int indexFrom, int paraTo, int indexTo, int selNum)
void Q3TextEdit::setSelection(int paraFrom, int indexFrom, int paraTo, int indexTo, int selNum)
To copy to clipboard, switch view to plain text mode
As far as I could get it,
For paraForm you need to give the index of starting Paragraph.
For paraTo you need to give index of ending Paragraph.
IndexFrom and IndexTo are actually cursur positions in the respective starting and ending paragraphs.
Obviously, give a different selNum each time.
PASTED FROM q3textedit.cpp
---------------------------------
[HTML]/*!
Sets a selection which starts at position \a indexFrom in
paragraph \a paraFrom and ends at position \a indexTo in paragraph
\a paraTo.
Any existing selections which have a different id (\a selNum) are
left alone, but if an existing selection has the same id as \a
selNum it is removed and replaced by this selection.
Uses the selection settings of selection \a selNum. If \a selNum
is 0, this is the default selection.
The cursor is moved to the end of the selection if \a selNum is 0,
otherwise the cursor position remains unchanged.
\sa getSelection() selectedText
*/[/HTML]
Thereafter you can use:
void Q3TextEdit::getSelection(int *paraFrom, int *indexFrom, int *paraTo, int *indexTo, int selNum) const
void Q3TextEdit::getSelection(int *paraFrom, int *indexFrom, int *paraTo, int *indexTo, int selNum) const
To copy to clipboard, switch view to plain text mode
You might have to dig into some codes in order to get info about QTextDocument, QTextParagraph and QTextCursor.
Out of these, QTextDocument, and QTextCursor is now documented in Qt4.
Using all these classes only you can have advanced selection facilities like Column selections (CTRL+ALT+mouse drag like in VC++ and TextPad).
- Shobhit
Bookmarks