PDA

View Full Version : Modified TextFinder example



LoomVortex
25th August 2009, 08:16
Hi!

I´m totally new to Qt and i´m trying to modify TextFinder example (http://doc.trolltech.com/4.5/uitools-textfinder.html) to copy specified number of characters AFTER the highlighted text? Example if we have a text...

""GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software"

and we try to find string "version"... program finds string "version" and copies 5 characters " 3.0 " after that to elsewhere (TextEdit). Any help how to do this would be great...

Thanks...

wysota
25th August 2009, 09:06
What did you already try?

LoomVortex
25th August 2009, 09:44
I created a new TextEdit Widget and I managed to copy searchString there with

ui->plainTextEdit->setPlainText(searchString);

OK, I know how to use TextEdit Widget (whee! :) ) but that doesn´t help me much because printed text it is the search string not the found text.

Also I managed to highlight rest of the line... so that highlighted text "version 3.0 as published by the Free Software" now includes the text "3.0" what i´m interested in. So the actual question is that what function i can use to copy the highlighted text?

wysota
25th August 2009, 11:13
See QTextCursor interface.

LoomVortex
26th August 2009, 11:17
Ok, it was easier than I expected.

"QTextCursor::selectedText ()" did the job. Thanks! :)