kringen
2nd June 2012, 06:05
Hello,
I am creating a "find" dialog for my text editor. I have the basic functionality working but I'm not having any luck with limiting the search to a selection only (this is a great feature in many code editors).
Here's where I am so far (This is the slot):
void MainWindow::findString(const QString str, int flags, bool selectionOnly)
{
QTextDocument::FindFlags ff = (QTextDocument::FindFlags)flags;
if(selectionOnly)
<Code for finding within selection goes here>
else
currentEditor->find(str,ff); // currentEditor is a QTextEdit
}
What would be the most efficient way to limit the search to only the selected text?
Any help is appreciated.
I am creating a "find" dialog for my text editor. I have the basic functionality working but I'm not having any luck with limiting the search to a selection only (this is a great feature in many code editors).
Here's where I am so far (This is the slot):
void MainWindow::findString(const QString str, int flags, bool selectionOnly)
{
QTextDocument::FindFlags ff = (QTextDocument::FindFlags)flags;
if(selectionOnly)
<Code for finding within selection goes here>
else
currentEditor->find(str,ff); // currentEditor is a QTextEdit
}
What would be the most efficient way to limit the search to only the selected text?
Any help is appreciated.