Search code examples
qt4scrollqtextedit

Find text in QTextEdit and scroll the line to top


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


Solution

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