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 to show a tool tip when a QLabel is clicked or pressed?
QtWS25 Last Chance

How to show a tool tip when a QLabel is clicked or pressed?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 1.6k 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.
  • ManiRonM Offline
    ManiRonM Offline
    ManiRon
    wrote on last edited by
    #1

    I want to show the tool tip for a QLabel , but i want to make the QLabel as hyperlink and when the link is pressed i want to pop the tool tip , Is there a way we can do this ?

    J.HilkJ 1 Reply Last reply
    0
    • ManiRonM ManiRon

      I want to show the tool tip for a QLabel , but i want to make the QLabel as hyperlink and when the link is pressed i want to pop the tool tip , Is there a way we can do this ?

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @ManiRon
      subclass QLabel, hijack the MousePressEvent and inside it call the static QToolTip::showText function


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      ManiRonM 1 Reply Last reply
      4
      • J.HilkJ J.Hilk

        @ManiRon
        subclass QLabel, hijack the MousePressEvent and inside it call the static QToolTip::showText function

        ManiRonM Offline
        ManiRonM Offline
        ManiRon
        wrote on last edited by
        #3

        @J.Hilk can you provide any sample please

        J.HilkJ 1 Reply Last reply
        0
        • ManiRonM ManiRon

          @J.Hilk can you provide any sample please

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @ManiRon

          https://wiki.qt.io/Clickable_QLabel
          https://forum.qt.io/topic/10532/how-to-show-tooltip-for-a-widget-from-code


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          ManiRonM 1 Reply Last reply
          3
          • J.HilkJ J.Hilk

            @ManiRon

            https://wiki.qt.io/Clickable_QLabel
            https://forum.qt.io/topic/10532/how-to-show-tooltip-for-a-widget-from-code

            ManiRonM Offline
            ManiRonM Offline
            ManiRon
            wrote on last edited by
            #5

            @J.Hilk How can i add this in my MainWindow

            Pl45m4P 1 Reply Last reply
            0
            • ManiRonM ManiRon

              @J.Hilk How can i add this in my MainWindow

              Pl45m4P Offline
              Pl45m4P Offline
              Pl45m4
              wrote on last edited by
              #6

              @ManiRon

              Create a new class that subclasses QLabel, then set it into a layout on your MainWindow
              OR
              you follow this to set a dummy widget (QLabel in your case) in Qt Designer where you want to have your custom label. Then promote it to your customLabel-class


              If debugging is the process of removing software bugs, then programming must be the process of putting them in.

              ~E. W. Dijkstra

              1 Reply Last reply
              3
              • Pradeep P NP Offline
                Pradeep P NP Offline
                Pradeep P N
                wrote on last edited by
                #7

                Hi @ManiRon

                Few reference examples hope these will help :

                • QT - How to apply a QToolTip on a QLineEdit.
                • Tool Tips Example

                All the best

                Pradeep Nimbalkar.
                Upvote the answer(s) that helped you to solve the issue...
                Keep code clean.

                1 Reply Last reply
                3

                • Login

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