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. QShortcut and fullscreen QWidget issue
Forum Update on Monday, May 27th 2025

QShortcut and fullscreen QWidget issue

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 1.1k 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.
  • Joel BodenmannJ Offline
    Joel BodenmannJ Offline
    Joel Bodenmann
    wrote on last edited by
    #1

    I have a QMainWindow with multiple QDockWidgets. Those dock widgets hold different QWidget based classes in them. For the sake of context: One of the docks contains a text editor widget. The text editor obviously uses keyboard input to modify the text content. However, that widget also uses QShortcuts to toggle the visibility of the search bar (Ctrl+F) and similar.

    What I am trying to add to my application is a QShortcut that allows the user making the currently focused QDockWidget become fullscreen temporarily. I added a new QShortcut and the corresponding slot-code to the QMainWindow class. So far everything works great: Pressing the key combination Ctrl+Alt+F will make the dock become fullscreen, pressing it again will put it back where it was before.
    However, my problem is that once the dock became fullscreen and I start clicking and typing around in the dock's widget (eg. that text editor), the key combination to make the dock leave the fullscreen mode no longer works.

    Does anybody have an idea what the issue is? The QShortcut in the QMainWindow has been configured to use Qt::ApplicationShortcut so I don't believe that it's a focus problem - yet the slot simply never gets called.

    QShortcut* shortcutToggleFullscreenCurrentDock = new QShortcut(this);
    shortcutToggleFullscreenCurrentDock->setContext(Qt::ApplicationShortcut);
    shortcutToggleFullscreenCurrentDock->setKey(ShortcutSequences::fullscreenCurrentDock());
    connect(shortcutToggleFullscreenCurrentDock, &QShortcut::activated, this, &MainWindow::dockToggleShowFullscreen);
    

    I'd be thankful for any kind of hint/tipp.

    Industrial process automation software: https://simulton.com
    Embedded Graphics & GUI library: https://ugfx.io

    raven-worxR 1 Reply Last reply
    0
    • Joel BodenmannJ Joel Bodenmann

      I have a QMainWindow with multiple QDockWidgets. Those dock widgets hold different QWidget based classes in them. For the sake of context: One of the docks contains a text editor widget. The text editor obviously uses keyboard input to modify the text content. However, that widget also uses QShortcuts to toggle the visibility of the search bar (Ctrl+F) and similar.

      What I am trying to add to my application is a QShortcut that allows the user making the currently focused QDockWidget become fullscreen temporarily. I added a new QShortcut and the corresponding slot-code to the QMainWindow class. So far everything works great: Pressing the key combination Ctrl+Alt+F will make the dock become fullscreen, pressing it again will put it back where it was before.
      However, my problem is that once the dock became fullscreen and I start clicking and typing around in the dock's widget (eg. that text editor), the key combination to make the dock leave the fullscreen mode no longer works.

      Does anybody have an idea what the issue is? The QShortcut in the QMainWindow has been configured to use Qt::ApplicationShortcut so I don't believe that it's a focus problem - yet the slot simply never gets called.

      QShortcut* shortcutToggleFullscreenCurrentDock = new QShortcut(this);
      shortcutToggleFullscreenCurrentDock->setContext(Qt::ApplicationShortcut);
      shortcutToggleFullscreenCurrentDock->setKey(ShortcutSequences::fullscreenCurrentDock());
      connect(shortcutToggleFullscreenCurrentDock, &QShortcut::activated, this, &MainWindow::dockToggleShowFullscreen);
      

      I'd be thankful for any kind of hint/tipp.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @Joel-Bodenmann said in QShortcut and fullscreen QWidget issue:

      connect(shortcutToggleFullscreenCurrentDock, &QShortcut::activated, this, &MainWindow::dockToggleShowFullscreen);

      try also (additionally) to connect to the activatedAmbiguously() signal

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      Joel BodenmannJ 1 Reply Last reply
      2
      • m.sueM Offline
        m.sueM Offline
        m.sue
        wrote on last edited by
        #3

        Hi,
        I assume a text editor (that has the focus) thinks that all keyboard events (like pressing character keys or CTRL-C, CTRL-V) are meant for it and swallows them. It does not delegate them to the parent widget.
        -Michael.

        1 Reply Last reply
        0
        • raven-worxR raven-worx

          @Joel-Bodenmann said in QShortcut and fullscreen QWidget issue:

          connect(shortcutToggleFullscreenCurrentDock, &QShortcut::activated, this, &MainWindow::dockToggleShowFullscreen);

          try also (additionally) to connect to the activatedAmbiguously() signal

          Joel BodenmannJ Offline
          Joel BodenmannJ Offline
          Joel Bodenmann
          wrote on last edited by
          #4

          @raven-worx said in QShortcut and fullscreen QWidget issue:

          try also (additionally) to connect to the activatedAmbiguously() signal

          That appears to be the trick! I haven't tested it with all the possible corner cases but so far it appears to be working nicely! Thank you very much for your help.

          @m.sue said in QShortcut and fullscreen QWidget issue:

          I assume a text editor (that has the focus) thinks that all keyboard events (like pressing character keys or CTRL-C, CTRL-V) are meant for it and swallows them. It does not delegate them to the parent widget.

          That is correct - but what do I have to do in order to still set up a truly application wide shortcut?
          I would have assume that shortcuts that the text editor doesn't know (eg. ALT + CTRL + F in my case) will simply be ignored and thus forwarded to the parent.

          Industrial process automation software: https://simulton.com
          Embedded Graphics & GUI library: https://ugfx.io

          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