View Full Version : Problem with Finding the Text
charlesprime
23rd March 2011, 05:25
Hi, am Using a Find Function in QTextEdit. I can find the Text.But I got some problem now..
Lets say i have 500 lines in the TextEdit. Whenever i click the Find Next Button, the text is found but i can see the word only by scrolling. So what i need is , whenever i click the Find Next Button, the Window should display the Current Found word
wysota
23rd March 2011, 08:07
Call QTextEdit::ensureCursorVisible().
charlesprime
24th March 2011, 05:24
Thanks for Reply..
Even i tried that thing , but its not working.
i will post my code:
Using QTextEdit::ExtraSelection //selecting the word.
Using QList<QTextEdit::ExtraSelection> //store the selected word.
i tried like this..
cursor.movePosition(selection[find].cursor.Start);
textEdit->setTextCursor(cursor);
textEdit->ensureCursorVisible();
Help me out.......
wysota
24th March 2011, 09:21
QTextEdit::find() already repositions the cursor. Just call ensureCursorVisible() then.
charlesprime
24th March 2011, 10:10
Thanks for reply....
i got a solution ....
cursor.setPosition(selection[i].cursor.position()); //set the textcursor poistion
textEdit->ensureCursorVisible();
its working fine .
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.