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. How scroll to a specific html tag in QTextEdit?
Forum Updated to NodeBB v4.3 + New Features

How scroll to a specific html tag in QTextEdit?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 438 Views 2 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.
  • A Offline
    A Offline
    abdoll78
    wrote on last edited by
    #1

    I write a some text in QTextEdit that have different background for some words. now i want to able to scroll to one of the them with pressing a button (like a next button).
    I try to add name to the span tags and then use scrollToAnchor() to move the scrollbar but when add html to text edit, it delete my name .

    myTextEdit.setHTML(<span name="scrollToMe">some thing</span>)
    myTextEdit.scrollToAnchor("scrollToMe")
    

    anyone know how to fix this?or another solution ?

    Pablo J. RoginaP 1 Reply Last reply
    0
    • A abdoll78

      I write a some text in QTextEdit that have different background for some words. now i want to able to scroll to one of the them with pressing a button (like a next button).
      I try to add name to the span tags and then use scrollToAnchor() to move the scrollbar but when add html to text edit, it delete my name .

      myTextEdit.setHTML(<span name="scrollToMe">some thing</span>)
      myTextEdit.scrollToAnchor("scrollToMe")
      

      anyone know how to fix this?or another solution ?

      Pablo J. RoginaP Offline
      Pablo J. RoginaP Offline
      Pablo J. Rogina
      wrote on last edited by
      #2

      @abdoll78 said in How scroll to a specific html tag in QTextEdit?:

      when add html to text edit, it delete my name

      Have you checked the documentation?

      The text can be set or replaced using setHtml() which deletes any existing text and replaces it with the text passed in the setHtml() call

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • A Offline
        A Offline
        abdoll78
        wrote on last edited by
        #3

        Of course
        I read it several times but can't find any solution for my problem!

        artwawA 1 Reply Last reply
        0
        • A abdoll78

          Of course
          I read it several times but can't find any solution for my problem!

          artwawA Offline
          artwawA Offline
          artwaw
          wrote on last edited by
          #4

          @abdoll78 solution is to parse your source text, add anchors in it, then set.

          For more information please re-read.

          Kind Regards,
          Artur

          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