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. CSS styling richtext in QTextDocument
Forum Updated to NodeBB v4.3 + New Features

CSS styling richtext in QTextDocument

Scheduled Pinned Locked Moved Solved General and Desktop
15 Posts 4 Posters 4.0k 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.
  • Christian EhrlicherC Offline
    Christian EhrlicherC Offline
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote on last edited by Christian Ehrlicher
    #2

    Qt does not support all HTML and CSS attributes - see https://doc.qt.io/qt-5/richtext-html-subset.html

    /edit: border-top-style: dotted; should work though... will take a look.

    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
    Visit the Qt Academy at https://academy.qt.io/catalog

    H 1 Reply Last reply
    0
    • Christian EhrlicherC Christian Ehrlicher

      Qt does not support all HTML and CSS attributes - see https://doc.qt.io/qt-5/richtext-html-subset.html

      /edit: border-top-style: dotted; should work though... will take a look.

      H Offline
      H Offline
      hullatom
      wrote on last edited by
      #3

      @Christian-Ehrlicher Hello, thank you. I know, it is what I say in the question. I use only those mentioned in supported subset as given in the link. Like width. But they do not work for some reason.

      1 Reply Last reply
      0
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #4

        At least I found the reason why border-style does no longer work - it was due to https://bugreports.qt.io/browse/QTBUG-36152 which added some new capabilities (border-collapse)

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        H 1 Reply Last reply
        1
        • Christian EhrlicherC Christian Ehrlicher

          At least I found the reason why border-style does no longer work - it was due to https://bugreports.qt.io/browse/QTBUG-36152 which added some new capabilities (border-collapse)

          H Offline
          H Offline
          hullatom
          wrote on last edited by
          #5

          @Christian-Ehrlicher I read it was fixed as of Qt 5.14. But I think I can live with that.

          I found that the width works as attribute. At least the relative % variant.

          Christian EhrlicherC 1 Reply Last reply
          0
          • fcarneyF Offline
            fcarneyF Offline
            fcarney
            wrote on last edited by
            #6

            I struggled with styling the html in QTextDocument. In my code I created an XML representation and then used XSLT stylesheet to convert to HTML. I am not completely satisfed with the output as I had issues making it look the way I wanted. I think I will eventually convert the XML to QML code on the fly. There were so many limitations with the HTML/CSS in QTextDocument it was very frustrating.

            C++ is a perfectly valid school of magic.

            H 1 Reply Last reply
            0
            • fcarneyF fcarney

              I struggled with styling the html in QTextDocument. In my code I created an XML representation and then used XSLT stylesheet to convert to HTML. I am not completely satisfed with the output as I had issues making it look the way I wanted. I think I will eventually convert the XML to QML code on the fly. There were so many limitations with the HTML/CSS in QTextDocument it was very frustrating.

              H Offline
              H Offline
              hullatom
              wrote on last edited by hullatom
              #7

              @fcarney Hello, thanks. Yes, it so limited that the use is only very basic. I am thinking of QML as well. But I never got in touch with that, and it is as learning whole new language. I do not know which way I would have to go. Well new adventure in front of me.

              I am also looking at this report designer: https://sourceforge.net/projects/qtrpt/

              What I like about HTML/CSS, is that everybody knows it, so it can be edited by any body who knows IT basics. I miss just few more styles and I would be happy.

              1 Reply Last reply
              0
              • H hullatom

                @Christian-Ehrlicher I read it was fixed as of Qt 5.14. But I think I can live with that.

                I found that the width works as attribute. At least the relative % variant.

                Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #8

                @hullatom said in CSS styling richtext in QTextDocument:

                I read it was fixed as of Qt 5.14.

                You read it wrong - I said that this fix introduced the regression about not honoring the border-style when using border-collapse.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                H 1 Reply Last reply
                0
                • Christian EhrlicherC Christian Ehrlicher

                  @hullatom said in CSS styling richtext in QTextDocument:

                  I read it was fixed as of Qt 5.14.

                  You read it wrong - I said that this fix introduced the regression about not honoring the border-style when using border-collapse.

                  H Offline
                  H Offline
                  hullatom
                  wrote on last edited by
                  #9

                  @Christian-Ehrlicher Maybe, it is somewhere in the text hidden? The summary on top of the page is saying:

                  https://bugreports.qt.io/browse/QTBUG-36152

                  Details
                  Type: Suggestion
                  Status:CLOSED
                  Priority: P4: Low
                  Resolution:Done
                  Affects Version/s:
                  5.2.0
                  Fix Version/s:
                  5.14.0 Alpha

                  Created: 13 Jan '14 22:56
                  Updated: 20 Aug '19 11:07
                  Resolved: 08 Aug '19 17:59

                  Christian EhrlicherC 1 Reply Last reply
                  0
                  • H hullatom

                    @Christian-Ehrlicher Maybe, it is somewhere in the text hidden? The summary on top of the page is saying:

                    https://bugreports.qt.io/browse/QTBUG-36152

                    Details
                    Type: Suggestion
                    Status:CLOSED
                    Priority: P4: Low
                    Resolution:Done
                    Affects Version/s:
                    5.2.0
                    Fix Version/s:
                    5.14.0 Alpha

                    Created: 13 Jan '14 22:56
                    Updated: 20 Aug '19 11:07
                    Resolved: 08 Aug '19 17:59

                    Christian EhrlicherC Offline
                    Christian EhrlicherC Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    @hullatom Read:

                    At least I found the reason why border-style does no longer work - it was due to https://bugreports.qt.io/browse/QTBUG-36152 which added some new capabilities (border-collapse)

                    border-style does not work together with border-collapse.

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    1 Reply Last reply
                    0
                    • Christian EhrlicherC Offline
                      Christian EhrlicherC Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on last edited by
                      #11

                      See https://codereview.qt-project.org/c/qt/qtbase/+/322891

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      1 Reply Last reply
                      0
                      • H Offline
                        H Offline
                        hullatom
                        wrote on last edited by
                        #12

                        Thank you all. In the end I managed to use the QtWebEngineView to render full html and css with no limitations.

                        1 Reply Last reply
                        1
                        • R Offline
                          R Offline
                          Rudresh
                          wrote on last edited by
                          #13

                          @hullatom said in CSS styling richtext in QTextDocument:

                          render

                          Hi ,
                          I read something about xml to html conversion but am not too sure
                          and also thread is quite old, but if anyone knows how to convert xml to html
                          ( qt 6.5 ) applying css -xslt , please let me know.

                          thanks & warm regards.
                          ~ Rudresh

                          Christian EhrlicherC 1 Reply Last reply
                          0
                          • R Rudresh

                            @hullatom said in CSS styling richtext in QTextDocument:

                            render

                            Hi ,
                            I read something about xml to html conversion but am not too sure
                            and also thread is quite old, but if anyone knows how to convert xml to html
                            ( qt 6.5 ) applying css -xslt , please let me know.

                            thanks & warm regards.
                            ~ Rudresh

                            Christian EhrlicherC Offline
                            Christian EhrlicherC Offline
                            Christian Ehrlicher
                            Lifetime Qt Champion
                            wrote on last edited by
                            #14

                            @Rudresh said in CSS styling richtext in QTextDocument:

                            ( qt 6.5 ) applying css -xslt , please let me know.

                            You have to use an external library for this. Qt does not provide this functionality in Qt6.

                            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                            Visit the Qt Academy at https://academy.qt.io/catalog

                            R 1 Reply Last reply
                            0
                            • Christian EhrlicherC Christian Ehrlicher

                              @Rudresh said in CSS styling richtext in QTextDocument:

                              ( qt 6.5 ) applying css -xslt , please let me know.

                              You have to use an external library for this. Qt does not provide this functionality in Qt6.

                              R Offline
                              R Offline
                              Rudresh
                              wrote on last edited by
                              #15

                              @Christian-Ehrlicher
                              Thanks a lot Christian.

                              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