Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved QLabel hyperlink and text-decoration

    General and Desktop
    3
    8
    2190
    Loading More Posts
    • 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.
    • SPlatten
      SPlatten last edited by SPlatten

      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 Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • SPlatten
          SPlatten last edited by

          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 Reply Quote 0
          • mrjj
            mrjj Lifetime Qt Champion last edited by

            @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 Reply Quote 0
            • SPlatten
              SPlatten last edited by

              @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

              mrjj 1 Reply Last reply Reply Quote 0
              • mrjj
                mrjj Lifetime Qt Champion @SPlatten last edited by 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 1 Reply Last reply Reply Quote 1
                • Q
                  QtTester @mrjj last edited by

                  @mrjj in the List of Properties, it says:

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

                  but it's still not working.

                  mrjj 1 Reply Last reply Reply Quote 0
                  • mrjj
                    mrjj Lifetime Qt Champion @QtTester last edited by

                    @QtTester
                    Can you show what you tried ?

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post