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] - Minimized window
Forum Update on Monday, May 27th 2025

[QML] - Minimized window

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

    Hi,
    For learning qml i try to write a simple game on my linux machine, i test it on android and my problem is exatly :

    I have a soundtrack in my game and a timer. When i minimize my window i want to stop the audio track and timer, but i don't find a method for my ApplicationWindow to discover if the window is hidden or not.

    Any help appreciate and sorry for my english ;-)

    Thanks

    Stéphane

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi @csgib
      Have a look at the property 'Qt.application.state' as described here:
      http://doc.qt.io/qt-5/qml-qtqml-qt.html#application-prop

      157

      1 Reply Last reply
      0
      • C Offline
        C Offline
        csgib
        wrote on last edited by
        #3

        Ok but i don't understand where / how place the event capture of application.state ... If i understand it's just a property not a event signal, no ?

        Thanks

        Stéphane

        raven-worxR 1 Reply Last reply
        0
        • C csgib

          Ok but i don't understand where / how place the event capture of application.state ... If i understand it's just a property not a event signal, no ?

          Thanks

          Stéphane

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

          @csgib
          read about QML's property bindings.
          This way you can use them like signals.

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

          1 Reply Last reply
          0
          • C Offline
            C Offline
            csgib
            wrote on last edited by
            #5

            Sorry but i don't understand something, i made this :
            ApplicationWindow {
            Application.state: {
            if (Application.state == Qt.ApplicationHidden)
            {
            console.log("I M MINIMIZED")
            }
            }
            }

            But when i compile i have this error :
            QQmlApplicationEngine failed to load component
            qrc:/main.qml:40 Non-existent attached object

            Line 40 is : Application.state: {

            I'm sorry but i'm very new in c++ / qml dev. Thanks for your help

            Stéphane

            raven-worxR 1 Reply Last reply
            0
            • C csgib

              Sorry but i don't understand something, i made this :
              ApplicationWindow {
              Application.state: {
              if (Application.state == Qt.ApplicationHidden)
              {
              console.log("I M MINIMIZED")
              }
              }
              }

              But when i compile i have this error :
              QQmlApplicationEngine failed to load component
              qrc:/main.qml:40 Non-existent attached object

              Line 40 is : Application.state: {

              I'm sorry but i'm very new in c++ / qml dev. Thanks for your help

              Stéphane

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

              @csgib
              try this:

              Connections {
                  target: Qt.application
                  onStateChanged:
                      if(Qt.application.state == Qt.ApplicationActive) {
                          console.log("ACTIVE")
                      }
                      else if(Qt.application.state == Qt.ApplicationSuspended) {
                           console.log("ISUSPENDED")
                      }
              }
              

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

              1 Reply Last reply
              0
              • C Offline
                C Offline
                csgib
                wrote on last edited by
                #7

                Ok thanks it works. I understand a better now.

                Thanks

                Stéphane

                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