Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Scrolling QTextEdit box to show found text
Qt 6.11 is out! See what's new in the release blog

Scrolling QTextEdit box to show found text

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 995 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    philchambers
    wrote on last edited by
    #1

    I've been using Qt on ubunto for some time and have written several programs. So far I have solved problems with Google but have now hit a brick wall with what must be a simple problem.

    I have a QPlainTextEdit box (read-only) containing a few hundred lines of text and have extracted the QTextDocument from it. I used the QTextDocument find() function to get a QTextCursor for the position of a particular word and have highligted it. So far so good. I now want to scroll the QPlainTextEdit box to show the word that was found.

    It must be simple but I have been unable to work out how to do it! Help will be much appreciated.

    1 Reply Last reply
    0
    • Chris KawaC Online
      Chris KawaC Online
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      After setting the cursor in the right place you can use "ensureCursorVisible()":http://qt-project.org/doc/qt-4.8/qplaintextedit.html#ensureCursorVisible.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        philchambers
        wrote on last edited by
        #3

        Thanks - simple when you know how!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved