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. dockWidget toggleViewAction and mnemonic handling
Forum Updated to NodeBB v4.3 + New Features

dockWidget toggleViewAction and mnemonic handling

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 881 Views 2 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.
  • P Offline
    P Offline
    Phil K
    wrote on last edited by
    #1

    Just upgraded from 5.12 to 5.14.2 on Windows and I notice a welcome patch that fixes the dock window title handling on fusion styling (and perhaps other styles) w.r.t. mnemonics. On 5.12, prior to the 5.14 upgrade, when issuing the api below, I would get a title with the typical shortcut rendering (ampersand becomes an underlined char). So that's fixed, great, but ...

    dock_widget->setWindowTitle("This & That");
    

    I also have a very typical "View" menu in which I have added a dock widget toggle via:

    view_menu->addAction(dock_widget->toggleViewAction());
    

    This is a nice feature that gives you a free checkbox in the view menu for that dock widget. The problem, however, is that view menu action follows the dock widget's title, but uses the mnemonic interpretation of the title and converts the ampersand to a shortcut. It's something I want to turn off for that particular action.

    My workaround is to connect to the view menu's aboutToShow signal and do this:

     QString title_no_mnemonic = dock_widget->windowTitle().replace("&", "&&");
     dock_widget_toggle_action->setText(title_no_mnemonic);
    

    Not sure if this is a reasonable way to do this, but perhaps the dockWidget's toggleViewAction should implicitly be free of such shortcut handling?

    Phil

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

      Hi,

      From the top of my head, shouldn't you use two ampersands in that case ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      P 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        From the top of my head, shouldn't you use two ampersands in that case ?

        P Offline
        P Offline
        Phil K
        wrote on last edited by
        #3

        @SGaist You mean in the setWindowTitle call?

        That api (happily) no longer converts mnemonics, so doubling the ampersand produces two ampersands in the display. No, the issue is that QDockWidget::toggleViewAction produces a QAction which does not do the same, i.e. it does convert mnemonics, so there is a lack of consistent treatment of window titles -- on the one hand I do not have to double-up (QDockWidget::setWindowTitle), but on the other hand I do have to double-up the ampersands (QDockWidget::toggleViewAction).

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

          Well, these two have different purposes so you cannot expect "consistency" here.

          It might be something that QDockWidget should do for you but it's not QAction's rôle to do that.

          Did you check the bug report system for something related ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          P 1 Reply Last reply
          0
          • SGaistS SGaist

            Well, these two have different purposes so you cannot expect "consistency" here.

            It might be something that QDockWidget should do for you but it's not QAction's rôle to do that.

            Did you check the bug report system for something related ?

            P Offline
            P Offline
            Phil K
            wrote on last edited by
            #5

            @SGaist I just checked and here is the code review and associated bug to the change I observed in my OP where the dock window title no longer tries to make mnemonic shortcuts. My issue, then, is a follow-on to that correction -- the QAction returned from QDockWidget::toggleViewAction should also ignore mnemonics since the only context in which the text of this action might be used would be for display of the title. There must be a QAction::setText happening internally when the dock widget title changes and perhaps that code might also be patched.

            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