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. Quit Application if another Window hides it (X11)

Quit Application if another Window hides it (X11)

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

    I have a small qml application which displays an animation on the screen if there is an inactivity by the user for some time.
    This application waits for "onClick" (we have a touchscreen only) and exits.
    But if another application is started, the application screen is not visible anymore and it never receives any mouseclick. In this case, it should also exit.

    But I don't know how how. I have tried to use some onXXX functions. The problem starts already that I cannot find a documentation which "onXXX" functions are already available.

    The application:

    import QtQuick 2.0

    Item {
    width: 1024
    height: 600
    MouseArea {
    onClicked: {
    console.log("onClicked");
    Qt.quit();
    }
    anchors.fill: parent
    }
    }

    AnimatedSprite {
    id: sprite
    width: 1024
    height: 600
    anchors.centerIn: parent
    source: "content/awibuben_spritesheet.png"
    frameCount: 5
    frameSync: true
    frameWidth: 1024
    frameHeight: 600
    }
    }

    I have also tried to use "Window" where I can receive "onActiveChanged", but the event comes only at the beginning but not when another fullscreen window is placed above this one.
    I use X11 with matchbox display manager.

    Any solutions?

    Not so nice, but it would also help to keep the application always in the foreground.

    B 1 Reply Last reply
    0
    • B benmao

      I have a small qml application which displays an animation on the screen if there is an inactivity by the user for some time.
      This application waits for "onClick" (we have a touchscreen only) and exits.
      But if another application is started, the application screen is not visible anymore and it never receives any mouseclick. In this case, it should also exit.

      But I don't know how how. I have tried to use some onXXX functions. The problem starts already that I cannot find a documentation which "onXXX" functions are already available.

      The application:

      import QtQuick 2.0

      Item {
      width: 1024
      height: 600
      MouseArea {
      onClicked: {
      console.log("onClicked");
      Qt.quit();
      }
      anchors.fill: parent
      }
      }

      AnimatedSprite {
      id: sprite
      width: 1024
      height: 600
      anchors.centerIn: parent
      source: "content/awibuben_spritesheet.png"
      frameCount: 5
      frameSync: true
      frameWidth: 1024
      frameHeight: 600
      }
      }

      I have also tried to use "Window" where I can receive "onActiveChanged", but the event comes only at the beginning but not when another fullscreen window is placed above this one.
      I use X11 with matchbox display manager.

      Any solutions?

      Not so nice, but it would also help to keep the application always in the foreground.

      B Offline
      B Offline
      benmao
      wrote on last edited by
      #2

      I have found a solution:

      The app exits, if the touch screen is pressed or if another application is started. Just as I wanted.

      import QtQuick 2.2
      import QtQuick.Window 2.1

      Item {

      Window { id: mainwindow
      width: 1024
      height: 600
      visible: true
      visibility: Window.Maximized

      modality: Qt.ApplicationModal
      // if it should stay on top:   flags: Qt.SplashScreen
      
      
      MouseArea {
          onClicked: Qt.quit();
          anchors.fill: parent
      }
      
      onActiveChanged: {
           console.log("onActiveChanged");
           if (active == 0) Qt.quit();
      }
      

      AnimatedSprite {
      id: sprite
      width: 1024
      height: 600
      anchors.centerIn: parent
      source: "content/awibuben_spritesheet.png"
      frameCount: 5
      frameSync: true
      frameWidth: 1024
      frameHeight: 600
      }
      }
      }

      1 Reply Last reply
      1

      • Login

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