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. QML - How to stop app from grabbing focus at startup

QML - How to stop app from grabbing focus at startup

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 805 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.
  • J Offline
    J Offline
    jimav
    wrote on last edited by
    #1

    How can an QML app completely avoid grabbing focus at startup?

    I want to run an app with qmlscene which displays its window but does not grab focus. In other words, keyboard and mouse stay focused on the (unrelated) window where they were before the app started (either by that other app, or a background activity).

    For example, to display a notifications without forcing the user to respond immediately.

    To get specific, how should the following be changed so that the Linux command

    qmlscene file.qml &
    

    does not take focus away from the terminal?

    import QtQuick 2.12
    import QtQuick.Controls 2.12
    
    ApplicationWindow {
      visible:true
       
      Text{ text: "Take care of this later" }
    }
    
    raven-worxR 1 Reply Last reply
    0
    • J jimav

      How can an QML app completely avoid grabbing focus at startup?

      I want to run an app with qmlscene which displays its window but does not grab focus. In other words, keyboard and mouse stay focused on the (unrelated) window where they were before the app started (either by that other app, or a background activity).

      For example, to display a notifications without forcing the user to respond immediately.

      To get specific, how should the following be changed so that the Linux command

      qmlscene file.qml &
      

      does not take focus away from the terminal?

      import QtQuick 2.12
      import QtQuick.Controls 2.12
      
      ApplicationWindow {
        visible:true
         
        Text{ text: "Take care of this later" }
      }
      
      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @jimav
      untested, but try the following:

      ApplicationWindow {
          flags: Qt.Tool
          // or
         flags: Qt.Window | Qt.WindowDoesNotAcceptFocus
      }
      

      Unfortunately the window flags are not supported the same on every platform.

      --- 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

      J 1 Reply Last reply
      2
      • raven-worxR raven-worx

        @jimav
        untested, but try the following:

        ApplicationWindow {
            flags: Qt.Tool
            // or
           flags: Qt.Window | Qt.WindowDoesNotAcceptFocus
        }
        

        Unfortunately the window flags are not supported the same on every platform.

        J Offline
        J Offline
        jimav
        wrote on last edited by
        #3

        @raven-worx flags works great, thanks.

        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