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. Rich Text Format to QTextEdit
Qt 6.11 is out! See what's new in the release blog

Rich Text Format to QTextEdit

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 2 Posters 9.9k 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi
    You should use
    http://doc.qt.io/qt-5/qtextedit.html#html-prop
    and look as the format it supports
    http://doc.qt.io/qt-5/richtext-html-subset.html

    I do not think it accept rich text as in RTF text, only html.
    So when docs says rich text it means text with formatting and NOT the rtf format.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mulfycrowh
      wrote on last edited by
      #3

      I already used html to change size, ... and it perfectly runs. The idea here was to use a RTF file generted by WordPad but as far I understand it is not possible.
      Thanks.

      mrjjM 1 Reply Last reply
      0
      • M mulfycrowh

        I already used html to change size, ... and it perfectly runs. The idea here was to use a RTF file generted by WordPad but as far I understand it is not possible.
        Thanks.

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #4

        @mulfycrowh
        Hi, I do not think it can parse and render traditional RTF at all.

        You can get a wonna-be WordPad with this example
        http://doc.qt.io/qt-5/qtwidgets-richtext-textedit-example.html

        I assume using wordpad was to provide a good editor.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mulfycrowh
          wrote on last edited by
          #5

          I've got another idea : writing the html sequence in a text file.
          If I use ->setPlainText(), it doesn't understand html sequences
          And if I use ->setText() it does understand thml sequences but without CRLF

          mrjjM 1 Reply Last reply
          0
          • M mulfycrowh

            I've got another idea : writing the html sequence in a text file.
            If I use ->setPlainText(), it doesn't understand html sequences
            And if I use ->setText() it does understand thml sequences but without CRLF

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #6

            @mulfycrowh
            Use the setHtml ?

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mulfycrowh
              wrote on last edited by
              #7

              If I use

              	ui.Text_About->setAcceptRichText(true);
              	QFile file("D:/help.txt");
              	file.open(QIODevice::ReadOnly | QIODevice::Text);
              	ui.Text_About->setHtml(file.readAll());
              	file.close();
              

              the sequences html are well understood but there are no more CRLF. That's a trouble ...

              1 Reply Last reply
              0
              • mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by mrjj
                #8

                well how are you making those line feeds?
                With html, \n \r dont count as far as i know.

                You must use <br> OR </p>

                1 Reply Last reply
                1
                • M Offline
                  M Offline
                  mulfycrowh
                  wrote on last edited by
                  #9

                  I just wrote it with Notepad.
                  Here are the very first lines:

                  <html><b>Format Generator</b></html>
                  <html><b>Developed by X - 09/17</b></html>
                  
                  
                  
                  <html><b>User's Manual</b></html>
                  
                  1/ Select Items Input Folder
                  This folder includes one item or several folders matching with various items.
                  
                  1 Reply Last reply
                  0
                  • mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    Try using QTextEdit editor
                    Right click a textedit and select "Change HTML "
                    make the html there.
                    Then it will work.
                    Notepad and just pressing enter will not.

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      mulfycrowh
                      wrote on last edited by
                      #11

                      You are right but with <br> it perfectly runs !

                      mrjjM 1 Reply Last reply
                      1
                      • M mulfycrowh

                        You are right but with <br> it perfectly runs !

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #12

                        @mulfycrowh
                        super .
                        make sure to flag as solved :)

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          mulfycrowh
                          wrote on last edited by
                          #13

                          Thank you again !

                          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