Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Regaining Focus after asynchronous notification
QtWS25 Last Chance

Regaining Focus after asynchronous notification

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 1.2k 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.
  • R Offline
    R Offline
    richterX
    wrote on last edited by
    #1

    Hello,
    I have a QML application that is fairly large with several dialogs, controls, views, etc. I am trying to have an asynchronous notification that requires the user's acknowledgement to close a message box. The problem is, the user could be doing a number of different things when the notification happens and I need to know how to return focus to the previous item.

    I know how to test for active focus of any one item, using the activeFocus method of Item. However, I could be anywhere in the application so I really need more of a global pointer to the active focus item in the application. I haven't been able to find such a call in QML, so hopefully I missed it. Does anyone know if there is such a thing? All I want to do is save a reference to the current focus item, open my dialog, and return focus to the previous item when the user has clicked "ok".

    Here is an example of how I dynamically create a dialog in another location and return focus back to the parent once the dialog is complete.
    @var component = Qt.createComponent("SimpleDialog.qml");
    if (component.status === Component.Ready) {
    var dlg = component.createObject(container);
    dlg.closed.connect(container.forceActiveFocus);
    dlg.title = "SomethingHappened";
    dlg.message = "Something happened.";
    dlg.forceActiveFocus();
    }
    else {
    console.log("Error loading SimpleDialog.qml:", component.errorString());
    }@

    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