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. Underlining words in a QTextEdit
Forum Updated to NodeBB v4.3 + New Features

Underlining words in a QTextEdit

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 1.2k 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.
  • F Offline
    F Offline
    Fuchsiaff
    wrote on last edited by
    #1

    I am working on a PyQt5 widget that shows the difference between 2 pieces of code and displays it visually

    Now, I need to underline certain lines in a QTextEdit but how do I do that?

    JonBJ raven-worxR 2 Replies Last reply
    0
    • F Fuchsiaff

      I am working on a PyQt5 widget that shows the difference between 2 pieces of code and displays it visually

      Now, I need to underline certain lines in a QTextEdit but how do I do that?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Fuchsiaff
      What about starting by reading through https://forum.qt.io/topic/70932/how-to-change-font-weight-at-various-locations-within-a-qtextedit

      That's the high-level. Otherwise I think you would be looking at writing code at the painting/drawing level.

      F 1 Reply Last reply
      0
      • F Fuchsiaff

        I am working on a PyQt5 widget that shows the difference between 2 pieces of code and displays it visually

        Now, I need to underline certain lines in a QTextEdit but how do I do that?

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by raven-worx
        #3

        @Fuchsiaff
        here's an example: https://wiki.qt.io/Spell-Checking-with-Hunspell (see Dialog::checkSpelling())
        in C++ though, but maybe it helps?

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        F 1 Reply Last reply
        4
        • JonBJ JonB

          @Fuchsiaff
          What about starting by reading through https://forum.qt.io/topic/70932/how-to-change-font-weight-at-various-locations-within-a-qtextedit

          That's the high-level. Otherwise I think you would be looking at writing code at the painting/drawing level.

          F Offline
          F Offline
          Fuchsiaff
          wrote on last edited by
          #4

          @JonB
          Styling with HTML is really not what I want to do since I want to apply the same technique later to a QPlainTextEdit.

          I have tried applying character formats on words before but that either made my program crash with a SIGSEGV error or crash without any errors

          1 Reply Last reply
          0
          • raven-worxR raven-worx

            @Fuchsiaff
            here's an example: https://wiki.qt.io/Spell-Checking-with-Hunspell (see Dialog::checkSpelling())
            in C++ though, but maybe it helps?

            F Offline
            F Offline
            Fuchsiaff
            wrote on last edited by
            #5

            @raven-worx That's exactly what I was looking for, thank you!

            JonBJ 1 Reply Last reply
            0
            • F Fuchsiaff

              @raven-worx That's exactly what I was looking for, thank you!

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @Fuchsiaff
              I don't understand: @raven-worx 's example uses QTextEdit and you just said you need to use QPlainTextEdit? It also does apply character formats to words".

              F 1 Reply Last reply
              0
              • JonBJ JonB

                @Fuchsiaff
                I don't understand: @raven-worx 's example uses QTextEdit and you just said you need to use QPlainTextEdit? It also does apply character formats to words".

                F Offline
                F Offline
                Fuchsiaff
                wrote on last edited by
                #7

                @JonB
                As long as it doesn't use html, it should work with both QTextEdit and QPlainTextEdit.

                1 Reply Last reply
                1

                • Login

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