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. focus and keyboard events in Widgets/Quick Applications
Forum Update on Monday, May 27th 2025

focus and keyboard events in Widgets/Quick Applications

Scheduled Pinned Locked Moved General and Desktop
focusqquickviewqwidget
2 Posts 1 Posters 1.0k 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.
  • P Offline
    P Offline
    pholz
    wrote on 11 Jun 2015, 12:33 last edited by
    #1

    I have an application that uses movable "modules", window-like widgets of different types. They all have a "titlebar" (another widget), "borders" (another outer widget) and an inner content widget. The content of some is implemented using QWidgets, the content of one uses a QQuickView, let's call it QuickUi.

    In QuickUi, I have various components, including a GridView. When the focus is on QuickUi (i.e. the user has most recently clicked somewhere in QuickUi), I want Ctrl+A to select all GridView tiles. When the focus is, i.e. in another module's text field, it should, of course, exhibit default behaviour (text selection).

    My first approach was using Actions in QuickUi. The problem is that when I click on QuickUi's module's borders widget and then back inside the QQuickView, in many cases the actions don't respond anymore. I then have to click in some other module and back into QuickUi...

    Second approach was to use a global event filter on the application object, and then distribute events via signals/slots. Works fine, except if I call a slot in QuickUi on Ctrl+A, I have to decide whether I have focus (and only trigger tile selection if I do). But how do I know that? focus and activeFocus on the QuickUi's root element is always false. I also don't get any focusInEvent calls in any of the container widgets...

    Is there any way I can find out which QWidget has the active focus, i.e. received the most recent mouse click?

    P 1 Reply Last reply 11 Jun 2015, 13:14
    0
    • P pholz
      11 Jun 2015, 12:33

      I have an application that uses movable "modules", window-like widgets of different types. They all have a "titlebar" (another widget), "borders" (another outer widget) and an inner content widget. The content of some is implemented using QWidgets, the content of one uses a QQuickView, let's call it QuickUi.

      In QuickUi, I have various components, including a GridView. When the focus is on QuickUi (i.e. the user has most recently clicked somewhere in QuickUi), I want Ctrl+A to select all GridView tiles. When the focus is, i.e. in another module's text field, it should, of course, exhibit default behaviour (text selection).

      My first approach was using Actions in QuickUi. The problem is that when I click on QuickUi's module's borders widget and then back inside the QQuickView, in many cases the actions don't respond anymore. I then have to click in some other module and back into QuickUi...

      Second approach was to use a global event filter on the application object, and then distribute events via signals/slots. Works fine, except if I call a slot in QuickUi on Ctrl+A, I have to decide whether I have focus (and only trigger tile selection if I do). But how do I know that? focus and activeFocus on the QuickUi's root element is always false. I also don't get any focusInEvent calls in any of the container widgets...

      Is there any way I can find out which QWidget has the active focus, i.e. received the most recent mouse click?

      P Offline
      P Offline
      pholz
      wrote on 11 Jun 2015, 13:14 last edited by
      #2

      I just did some more experiments and it seems that if I subclass QQuickView and put debug outputs in the focusInEvent and focusOutEvent handlers, there are cases in which clicking any element in the QML structure gives the quickview focus, but in other cases (e.g. when I click on one of the "border" widgets, not necessarily its own one, and then back into it) it doesn't get focus. How is that possible?

      1 Reply Last reply
      0

      1/2

      11 Jun 2015, 12:33

      • Login

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