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. QTextBrowser and <hr color=
Forum Updated to NodeBB v4.3 + New Features

QTextBrowser and <hr color=

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 547 Views 3 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.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by
    #1

    Given:

    QColor windowTextColour = palette.color(QPalette::WindowText);
    

    I tried:

    textBrowser.insertHtml(QString("<hr color=\"") + windowTextColour.name() + "\">");
    

    Which comes out to <hr color="#ffffff"> if a dark theme is active.

    but the hr displayed was dark, not white as requested.

    Did I get the incantation wrong or does the text browser not support specifying color= in an <hr> tag?

    Thanks
    David

    JonBJ Chris KawaC 2 Replies Last reply
    0
    • PerdrixP Perdrix

      Given:

      QColor windowTextColour = palette.color(QPalette::WindowText);
      

      I tried:

      textBrowser.insertHtml(QString("<hr color=\"") + windowTextColour.name() + "\">");
      

      Which comes out to <hr color="#ffffff"> if a dark theme is active.

      but the hr displayed was dark, not white as requested.

      Did I get the incantation wrong or does the text browser not support specifying color= in an <hr> tag?

      Thanks
      David

      Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #3

      @Perdrix color attribute corresponds to the text color of the content of given element. <hr> is not a textual element, nor does it have content. You can style the look of it via stylesheet:

      tb->insertHtml("<hr style=\"background-color:" + windowTextColor.name() + "\">");
      

      or simply:

      tb->insertHtml("<hr style=\"background-color: palette(windowText)\">");
      
      PerdrixP 1 Reply Last reply
      2
      • PerdrixP Perdrix

        Given:

        QColor windowTextColour = palette.color(QPalette::WindowText);
        

        I tried:

        textBrowser.insertHtml(QString("<hr color=\"") + windowTextColour.name() + "\">");
        

        Which comes out to <hr color="#ffffff"> if a dark theme is active.

        but the hr displayed was dark, not white as requested.

        Did I get the incantation wrong or does the text browser not support specifying color= in an <hr> tag?

        Thanks
        David

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

        @Perdrix
        Supported Tags

        hr Horizontal line Supports the width attribute, which can be specified as an absolute or relative (%) value.

        You can keep asking about each individual tag, but I doubt anyone knows any better than what is listed in "Supported Tags". You can also try <hr color="red"/> in a standalone document with no palette/dark mode and verify that does not work.

        In the case of hr tag what evidence do you have that HTML respects color on it anyway? See e.g. https://stackoverflow.com/questions/6979848/horizontal-line-in-qtextedit for this and what you might do (e.g. div?).

        1 Reply Last reply
        0
        • PerdrixP Perdrix

          Given:

          QColor windowTextColour = palette.color(QPalette::WindowText);
          

          I tried:

          textBrowser.insertHtml(QString("<hr color=\"") + windowTextColour.name() + "\">");
          

          Which comes out to <hr color="#ffffff"> if a dark theme is active.

          but the hr displayed was dark, not white as requested.

          Did I get the incantation wrong or does the text browser not support specifying color= in an <hr> tag?

          Thanks
          David

          Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #3

          @Perdrix color attribute corresponds to the text color of the content of given element. <hr> is not a textual element, nor does it have content. You can style the look of it via stylesheet:

          tb->insertHtml("<hr style=\"background-color:" + windowTextColor.name() + "\">");
          

          or simply:

          tb->insertHtml("<hr style=\"background-color: palette(windowText)\">");
          
          PerdrixP 1 Reply Last reply
          2
          • PerdrixP Perdrix has marked this topic as solved on
          • Chris KawaC Chris Kawa

            @Perdrix color attribute corresponds to the text color of the content of given element. <hr> is not a textual element, nor does it have content. You can style the look of it via stylesheet:

            tb->insertHtml("<hr style=\"background-color:" + windowTextColor.name() + "\">");
            

            or simply:

            tb->insertHtml("<hr style=\"background-color: palette(windowText)\">");
            
            PerdrixP Offline
            PerdrixP Offline
            Perdrix
            wrote on last edited by
            #4

            @Chris-Kawa Kudos!

            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