Qt Forum

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

    Solved QAction shortcuts completely innaccessible when undocking a window

    General and Desktop
    2
    7
    251
    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.
    • C
      chrisbegames last edited by

      Hello,

      I am posting this topic to ask for some support or insight on the issue I have been experiencing with our tool which UI is powered by Qt:

      I have a window (Lets call it Explorer) that shows you a hierarchy tree of files. The window contains a QWidget which itself contains a QAbstractScrollArea. We have setup QActions both at the Widget level and at the MainWindow (The top level application). Shortcuts to these actions work as expected while the window is docked to the Editor. As soon as the window is undocked, shortcuts do not work anymore. Other windows are working fine however. I have been looking at discrepancies between this new window and the other windows that work, but at this point I am not sure of what I may be missing.

      I would be interested on having an idea of what can cause a QAction to not get an event. I have been debugging our main eventFilter and when the window is docked, we get a Shortcut Event targeted to a QAction object. When undocked, QAction never gets to the eventFilter. Interesting enough, if I click the window itself (When undocked) the shortcuts work. When I click one of the items in the hierarchy list of the tree view, the shortcuts stop working.

      I haven't been able to find good documentation of what can cause a QAction to stop receiving events. Any insight or advice will be highly appreciated.

      Thanks,

      Christian

      1 Reply Last reply Reply Quote 0
      • C
        chrisbegames last edited by

        Okay I may have found the culprit, I still do not understand why.

        In the focused widget (TreeView), we are implementing the mouseReleaseEvent. I noticed that once I click in the hierarchy item, if we intercepted the tree view we accept the event (event->accept()) and we skip calling the base class's mouseReleaseEvent (QAbstractScrollArea::mouseReleaseEvent). If I ensure the latter is called, the shortcuts work fine when the window is undocked.

        I still do not understand the following:

        a) Why is this not affecting the shortcuts when the widget is docked to the main window of the application?

        b) How would not calling mouseReleaseEvent of the base class somehow prevent the QActions to get triggered?

        1 Reply Last reply Reply Quote 0
        • SGaist
          SGaist Lifetime Qt Champion last edited by

          Hi and welcome to devnet,

          So if understand you correctly, when undocked and out of focus, the actions associated to that widget aren't triggered, correct ?

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

          C 1 Reply Last reply Reply Quote 0
          • C
            chrisbegames @SGaist last edited by

            @SGaist

            Hey SGaist,

            When undocked, I click in one of the items of the file hierarchy and actions are not triggered (Not just the ones associated with the widget, but even those added to the Main Window)

            Cheers,

            Christian

            1 Reply Last reply Reply Quote 0
            • SGaist
              SGaist Lifetime Qt Champion last edited by

              Can you show how you setup your action ?

              Depending on how you did that, it's the widget which has the keyboard focus that will handle the actions associated with it.

              See the ShortcutContext enum.

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

              1 Reply Last reply Reply Quote 1
              • C
                chrisbegames last edited by

                Okay I may have found the culprit, I still do not understand why.

                In the focused widget (TreeView), we are implementing the mouseReleaseEvent. I noticed that once I click in the hierarchy item, if we intercepted the tree view we accept the event (event->accept()) and we skip calling the base class's mouseReleaseEvent (QAbstractScrollArea::mouseReleaseEvent). If I ensure the latter is called, the shortcuts work fine when the window is undocked.

                I still do not understand the following:

                a) Why is this not affecting the shortcuts when the widget is docked to the main window of the application?

                b) How would not calling mouseReleaseEvent of the base class somehow prevent the QActions to get triggered?

                1 Reply Last reply Reply Quote 0
                • SGaist
                  SGaist Lifetime Qt Champion last edited by

                  Not calling the base class implementation means that whatever the base class was doing does not happen. It could be focus handling.

                  When docked, your widget is in the same focus level as the others.

                  When undocked, it is separated thus handled separately.

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

                  1 Reply Last reply Reply Quote 2
                  • C
                    chrisbegames last edited by

                    Sounds good. Thanks for your replies SGaist!

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