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

Rich Text Format to QTextEdit

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 2 Posters 7.3k Views
  • 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.
  • M Offline
    M Offline
    mrjj
    Lifetime Qt Champion
    wrote on 18 Sept 2016, 10:39 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 18 Sept 2016, 10:48 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.

      M 1 Reply Last reply 18 Sept 2016, 11:40
      0
      • M mulfycrowh
        18 Sept 2016, 10:48

        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.

        M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 18 Sept 2016, 11:40 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 18 Sept 2016, 14:53 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

          M 1 Reply Last reply 18 Sept 2016, 15:25
          0
          • M mulfycrowh
            18 Sept 2016, 14:53

            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

            M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 18 Sept 2016, 15:25 last edited by
            #6

            @mulfycrowh
            Use the setHtml ?

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mulfycrowh
              wrote on 18 Sept 2016, 15:33 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
              • M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 18 Sept 2016, 15:38 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 18 Sept 2016, 15:47 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
                  • M Offline
                    M Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 18 Sept 2016, 15:50 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 18 Sept 2016, 15:53 last edited by
                      #11

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

                      M 1 Reply Last reply 18 Sept 2016, 16:21
                      1
                      • M mulfycrowh
                        18 Sept 2016, 15:53

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

                        M Offline
                        M Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on 18 Sept 2016, 16:21 last edited by
                        #12

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

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          mulfycrowh
                          wrote on 18 Sept 2016, 16:34 last edited by
                          #13

                          Thank you again !

                          1 Reply Last reply
                          1

                          11/13

                          18 Sept 2016, 15:53

                          • Login

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