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. Wrong text format in QTextEdit after setHtml is called
Forum Updated to NodeBB v4.3 + New Features

Wrong text format in QTextEdit after setHtml is called

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 633 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.
  • J Offline
    J Offline
    juanti
    wrote on last edited by
    #1
    This post is deleted!
    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Have you changed the wrap mode?

      (Z(:^

      1 Reply Last reply
      0
      • J Offline
        J Offline
        juanti
        wrote on last edited by
        #3

        Yes I've tried all possible ways using setWordWrapMode and setLineWrapMode, but still no effect...

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Does the HTML specify custom style, or <pre> element? It may be disabling Qt's own handling of strings.

          Plus, have you verified that only tags supported by Qt are used? Qt RichText supports only a limited subset of HTML.

          (Z(:^

          1 Reply Last reply
          0
          • J Offline
            J Offline
            juanti
            wrote on last edited by juanti
            #5

            Well the only tags that are used are: <span style...>, <br> and &nbsp .. that's all tags I use.
            U can see the html, I've posted a link (https://drive.google.com/open?id=1ZIPjzXgAgEFci5O1zZ20DhQ-OFxqqKYf)

            B 1 Reply Last reply
            0
            • J juanti

              Well the only tags that are used are: <span style...>, <br> and &nbsp .. that's all tags I use.
              U can see the html, I've posted a link (https://drive.google.com/open?id=1ZIPjzXgAgEFci5O1zZ20DhQ-OFxqqKYf)

              B Offline
              B Offline
              Bonnie
              wrote on last edited by Bonnie
              #6

              @juanti Hi, I've tried that if you replace all the "&nbsp;" in your html with real spaces, the text will wrap as you expecting.

              1 Reply Last reply
              2
              • J Offline
                J Offline
                juanti
                wrote on last edited by juanti
                #7

                @Bonnie , yes but there are times where I have 2 or more addition spaces, and if I don't replace the spaces with "&nbsp", they get destroyed to one.

                JonBJ 1 Reply Last reply
                0
                • J juanti

                  @Bonnie , yes but there are times where I have 2 or more addition spaces, and if I don't replace the spaces with "&nbsp", they get destroyed to one.

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

                  @juanti
                  But from what @Bonnie said, you are wanting text to wrap where you have &nbsp;s and that is your issue, correct? You can't have them where you want wrap, the point is they forbid wrap.

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    juanti
                    wrote on last edited by
                    #9

                    @juanti said in Wrong text format in QTextEdit after setHtml is called:

                    &nbsp
                    Thanks guys. I found a solution for the problem. So just add <pre> tag at the begining and the end of the html and replace nbsp with " " and it would work.

                    Thanks everyone !

                    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