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. Tooltips on a QAction used for a menu entry and a toolbar button
Forum Updated to NodeBB v4.3 + New Features

Tooltips on a QAction used for a menu entry and a toolbar button

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 2 Posters 873 Views 1 Watching
  • 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.
  • B Offline
    B Offline
    buhtz
    wrote on last edited by
    #1

    I discovered a conceptual problem. And I hope that Qt still has an elegant solution for it. I do use PyQt but I am sure this is not related to Python itself.

    I do use QAction and set them up with a tooltip. Then I use this QAction to create 1) a menu entry in the main windows menubar and 2) in the main windows toolbar (just using icons without labels).

    Beside the tooltip the menu entry has a label string that describe its function. The tooltip just gives some more details or background information.

    But the same tooltip is used for the toolbar button which do not have a label string but just an icon. So a user who do not know the function of that button, hover the mouse over it to get the tooltlip. But the tooltip do not describe the function (in short words) but give more details.

    Conceptual I imagine a solution where I can add two kinds tooltips to a QAction: One for elements with a label and one for elements without a label.

    Another approach would be to rewrite the tooltip that way that it would work for both situations.

    The last (but blowing up code) approach would be to have two separate QActions.

    Any other ideas?

    A real world example of that problem including a screencast is described in this issue:
    https://github.com/bit-team/backintime/issues/1605

    JonBJ 1 Reply Last reply
    0
    • B buhtz

      I discovered a conceptual problem. And I hope that Qt still has an elegant solution for it. I do use PyQt but I am sure this is not related to Python itself.

      I do use QAction and set them up with a tooltip. Then I use this QAction to create 1) a menu entry in the main windows menubar and 2) in the main windows toolbar (just using icons without labels).

      Beside the tooltip the menu entry has a label string that describe its function. The tooltip just gives some more details or background information.

      But the same tooltip is used for the toolbar button which do not have a label string but just an icon. So a user who do not know the function of that button, hover the mouse over it to get the tooltlip. But the tooltip do not describe the function (in short words) but give more details.

      Conceptual I imagine a solution where I can add two kinds tooltips to a QAction: One for elements with a label and one for elements without a label.

      Another approach would be to rewrite the tooltip that way that it would work for both situations.

      The last (but blowing up code) approach would be to have two separate QActions.

      Any other ideas?

      A real world example of that problem including a screencast is described in this issue:
      https://github.com/bit-team/backintime/issues/1605

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @buhtz said in Tooltips on a QAction used for a menu entry and a toolbar button:

      Another approach would be to rewrite the tooltip that way that it would work for both situations.

      Isn't this what is best/wanted?

      B 1 Reply Last reply
      0
      • JonBJ JonB

        @buhtz said in Tooltips on a QAction used for a menu entry and a toolbar button:

        Another approach would be to rewrite the tooltip that way that it would work for both situations.

        Isn't this what is best/wanted?

        B Offline
        B Offline
        buhtz
        wrote on last edited by
        #3

        @JonB said in Tooltips on a QAction used for a menu entry and a toolbar button:

        Isn't this what is best/wanted?

        For me I would say "no". Because it blows up the tooltip in the meaning of word/character count. This is because then it tries to fulfill two intentions: 1) Label the function or short naming 2) longer description of the function or details about it.

        Of course this is possible and easy to solve. But I might have missed a Qt feature solving my problem in a more elegant way.

        JonBJ 1 Reply Last reply
        0
        • B buhtz

          @JonB said in Tooltips on a QAction used for a menu entry and a toolbar button:

          Isn't this what is best/wanted?

          For me I would say "no". Because it blows up the tooltip in the meaning of word/character count. This is because then it tries to fulfill two intentions: 1) Label the function or short naming 2) longer description of the function or details about it.

          Of course this is possible and easy to solve. But I might have missed a Qt feature solving my problem in a more elegant way.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @buhtz
          [I see someone has commented same as my reaction on your link.]

          Could you point to an example of an application (not yours, something well known) which uses a menu entry and a toolbar button with a tooltip, and the tooltip differs per your scenario? Then you will know what to follow.

          B 1 Reply Last reply
          0
          • JonBJ JonB

            @buhtz
            [I see someone has commented same as my reaction on your link.]

            Could you point to an example of an application (not yours, something well known) which uses a menu entry and a toolbar button with a tooltip, and the tooltip differs per your scenario? Then you will know what to follow.

            B Offline
            B Offline
            buhtz
            wrote on last edited by
            #5

            I will look around for examples.

            JonBJ 1 Reply Last reply
            0
            • B buhtz

              I will look around for examples.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @buhtz
              It would seem a shame to duplicate a QAction just for the sake of a slight tooltip text adjustment. I think I recall that Qt framework allows you to manage displaying tooltips yourself if you want. There you might be able to tell where it is being shown and alter text correspondingly....

              ...Ah, have a look at https://doc.qt.io/qt-6/qtooltip.html#details

              It is also possible to show different tool tips for different regions of a widget, by using a QHelpEvent of type QEvent::ToolTip. Intercept the help event in your widget's event() function and call QToolTip::showText() with the text you want to display.

              B 1 Reply Last reply
              1
              • JonBJ JonB

                @buhtz
                It would seem a shame to duplicate a QAction just for the sake of a slight tooltip text adjustment. I think I recall that Qt framework allows you to manage displaying tooltips yourself if you want. There you might be able to tell where it is being shown and alter text correspondingly....

                ...Ah, have a look at https://doc.qt.io/qt-6/qtooltip.html#details

                It is also possible to show different tool tips for different regions of a widget, by using a QHelpEvent of type QEvent::ToolTip. Intercept the help event in your widget's event() function and call QToolTip::showText() with the text you want to display.

                B Offline
                B Offline
                buhtz
                wrote on last edited by
                #7

                Thanks for the tip.

                I assume that it is hard to find an application that do use tooltips for their menu entries. It might be an unusual use case I do have here.

                JonBJ 1 Reply Last reply
                0
                • B buhtz

                  Thanks for the tip.

                  I assume that it is hard to find an application that do use tooltips for their menu entries. It might be an unusual use case I do have here.

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by JonB
                  #8

                  @buhtz
                  It was just an illustration that you might be overcomplicating this, other apps just give you a tooltip and you get on with it, it's not always perfect :) But yes if you do want to change the text I think follow the QHelpEvent approach.

                  Conceptual I imagine a solution where I can add two kinds tooltips to a QAction: One for elements with a label and one for elements without a label.

                  That is just not supported. And methods are not virtual to allow subclass/override.

                  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