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. QLabel hyperlink and text-decoration
QtWS25 Last Chance

QLabel hyperlink and text-decoration

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 4.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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by SPlatten
    #1

    I have a working hyperlink using a QLabel, the link is underlined, I've tried removing the underline by setting the CSS property text-decoration to none in the style sheet.

    This has no effect, is there another way to prevent the hyperlink from having an underline?

    This is the CSS I have now:

    QLabel { align:left,top;
            border:0px;
             color:#ff0000;
         font-size:40pt;
            format:rich;
    text-decoration:none;}
    

    The alignment and font-size work, the color and text-decoration don't work.

    Kind Regards,
    Sy

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

      Hi
      This works for me.

      myLabel->setText("<a style= text-decoration:none; href=\"http://example.com/\">Click Here!</a>");
      

      alt text

      1 Reply Last reply
      0
      • SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by
        #3

        Interesting, I will try that, why doesn't it work when I call:

            setText(strText);
            setFont(clsXMLnode::objFont());
            setWindowFlag(Qt::FramelessWindowHint);     // No frame
        
            if ( strText.contains(clsXMLnode::mscszAhref) == true ) {
                setOpenExternalLinks(true);
            }
            if ( *pstrCSS != nullptr && pstrCSS->isEmpty() != true ) {            
                if ( pstrCSS->indexOf(clsXMLnode::mscszCSSbackgroundColour) >= -1 ) {
                    blnBackground = true;
                }
                setStyleSheet(*pstrCSS);
            }
        

        Where strText contains:

        <a href="http://google.com">Google</a>
        

        And the *pstrCSS contains:

         QLabel { align:left,top;
                 border:0;
                  color:#ff0000;
              font-size:40pt
                 format:rich;
        text-decoration:none;}
        

        Kind Regards,
        Sy

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

          @SPlatten said in QLabel hyperlink and text-decoration:

          text-decoration:none

          I don't see that listed as a Qt style thing.
          https://doc.qt.io/qt-5/stylesheet-reference.html

          So im not sure it can work that way.

          1 Reply Last reply
          0
          • SPlattenS Offline
            SPlattenS Offline
            SPlatten
            wrote on last edited by
            #5

            @mrjj , I was assuming that since this isn't a very new addition to the CSS standard that Qt would support it. Isn't your example using exactly the same syntax?

            Kind Regards,
            Sy

            mrjjM 1 Reply Last reply
            0
            • SPlattenS SPlatten

              @mrjj , I was assuming that since this isn't a very new addition to the CSS standard that Qt would support it. Isn't your example using exactly the same syntax?

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

              @SPlatten

              Well it is supported
              https://doc.qt.io/qt-5/richtext-html-subset.html
              in the HTML subset but i have not seen it for the style sheet support.
              ( in use i mean. it should work but seem to get ignored in CSS )

              Im using it in HTML style and you try with the Qt Widget stylesheet.

              Q 1 Reply Last reply
              1
              • mrjjM mrjj

                @SPlatten

                Well it is supported
                https://doc.qt.io/qt-5/richtext-html-subset.html
                in the HTML subset but i have not seen it for the style sheet support.
                ( in use i mean. it should work but seem to get ignored in CSS )

                Im using it in HTML style and you try with the Qt Widget stylesheet.

                Q Offline
                Q Offline
                QtTester
                wrote on last edited by
                #7

                @mrjj in the List of Properties, it says:

                text-decoration	none
                underline
                overline
                line-through	Additional text effects
                

                but it's still not working.

                mrjjM 1 Reply Last reply
                0
                • Q QtTester

                  @mrjj in the List of Properties, it says:

                  text-decoration	none
                  underline
                  overline
                  line-through	Additional text effects
                  

                  but it's still not working.

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

                  @QtTester
                  Can you show what you tried ?

                  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