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=
QtWS25 Last Chance

QTextBrowser and <hr color=

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 505 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.
  • P Offline
    P Offline
    Perdrix
    wrote on 27 May 2023, 10:18 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

    J C 2 Replies Last reply 27 May 2023, 10:43
    0
    • P Perdrix
      27 May 2023, 10:18

      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

      C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 27 May 2023, 17:21 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)\">");
      
      P 1 Reply Last reply 28 May 2023, 07:47
      2
      • P Perdrix
        27 May 2023, 10:18

        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

        J Offline
        J Offline
        JonB
        wrote on 27 May 2023, 10:43 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
        • P Perdrix
          27 May 2023, 10:18

          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

          C Offline
          C Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on 27 May 2023, 17:21 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)\">");
          
          P 1 Reply Last reply 28 May 2023, 07:47
          2
          • P Perdrix has marked this topic as solved on 28 May 2023, 07:47
          • C Chris Kawa
            27 May 2023, 17:21

            @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)\">");
            
            P Offline
            P Offline
            Perdrix
            wrote on 28 May 2023, 07:47 last edited by
            #4

            @Chris-Kawa Kudos!

            1 Reply Last reply
            0

            3/4

            27 May 2023, 17:21

            • Login

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