views:

15

answers:

1

There is a QListWidget containing keywords for search and a QTextEdit containing some text. Clicking on one of the keywords should result in matching the word in the QTextEdit and scrolling the corresponding line to the top.

I connect the QListWidget and the QTextEdit with signal/slot and perform a QTextEdit::find(), which almost results in the desired behavior. But unfortunately the line containing the keyword is not scrolled to the top, rather it is on the bottom of the QTextEdit. How can I easily achieve my goal?

Thanks for your help,

Chris

+2  A: 

Could you try scrolling to the end of the QTextEdit, then searching? That way it would scroll up to the found word.

Skilldrick
That worked, thanks! Move the cursor to the end and then search backwards... now that you are came up with the solution it seems so clear and easy ;)
Chris
@Chris Excellent, happy to help :)
Skilldrick