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. How can we create hyper link text in QtGui?
QtWS25 Last Chance

How can we create hyper link text in QtGui?

Scheduled Pinned Locked Moved General and Desktop
12 Posts 4 Posters 9.8k 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
    pratik041
    wrote on last edited by
    #1

    I want to display some hyperlink text in my window so that user can interact through it.

    Pratik Agrawal

    1 Reply Last reply
    0
    • I Offline
      I Offline
      Iktwo
      wrote on last edited by
      #2

      Hi, QLabel has a property called openExternalLinks that you need to set to true, don't know if you need something else, hope it helps you

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pratik041
        wrote on last edited by
        #3

        But i think Qlabel dont provide user interaction.

        Pratik Agrawal

        1 Reply Last reply
        0
        • I Offline
          I Offline
          Iktwo
          wrote on last edited by
          #4

          when you say user interaction you mean like an edit? where you can write? why don't you write in the edit a copy it to a label with a link?

          1 Reply Last reply
          0
          • P Offline
            P Offline
            pratik041
            wrote on last edited by
            #5

            Ok, does Qlabel will respond to click event?

            Pratik Agrawal

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #6

              Yes, you can use QLabel. You can put rich text (basically, HTML) in it, including links. You will get signals if users hover or click these HTML links. QLabel does not react to other types of user interaction though. You can use those signals to handle the actions internally. If you want a webbrowser to open, set the openExternalLinks property to true as suggested by Iktwo.

              1 Reply Last reply
              0
              • P Offline
                P Offline
                pratik041
                wrote on last edited by
                #7

                I have tried this but Does We can't call any slot by using this?

                Pratik Agrawal

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  cincirin
                  wrote on last edited by
                  #8

                  Connect your slot to "QLabel::linkActivated":http://doc.qt.nokia.com/stable/qlabel.html#linkActivated

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    andre
                    wrote on last edited by
                    #9

                    I am sorry, I do not understand what you mean by this question.

                    I am using the method in an application I build, so I am postive it works.

                    1 Reply Last reply
                    0
                    • P Offline
                      P Offline
                      pratik041
                      wrote on last edited by
                      #10

                      I am using
                      @ QObject::connect (l, SIGNAL(linkActivated(QString)), wi, SLOT(open()));@

                      but the slot is not get called . Here l is label and wi is any slot.

                      Pratik Agrawal

                      1 Reply Last reply
                      0
                      • C Offline
                        C Offline
                        cincirin
                        wrote on last edited by
                        #11

                        The linkActivated() signal is not emitted if you set "openExternalLinks":http://doc.qt.nokia.com/stable/qlabel.html#openExternalLinks-prop to true

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          andre
                          wrote on last edited by
                          #12

                          [quote author="cincirin" date="1319184392"]The linkActivated() signal is not emitted if you set "openExternalLinks":http://doc.qt.nokia.com/stable/qlabel.html#openExternalLinks-prop to true[/quote]
                          Good point :-)

                          Also: it might be useful to check the return value of the connect statement and/or the output of the application. If the return value is false, the connect failed. The debug output of the application should tell you what the cause of that failure is.

                          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