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 application closing issue
Forum Update on Monday, May 27th 2025

Qml application closing issue

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qt 5.4qmlc++
3 Posts 3 Posters 600 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
    praveen_03
    wrote on 11 Sept 2023, 10:16 last edited by
    #1

    I'm building one qml application and I printing console log's every where but if I minimize application and try to close from taskbar how will I capture that close event in console log

    Component.onCompleted: {
           Qt.application.activeChanged.connect(function() {
               if (!Qt.application.active) {
                   console.log("Application closed from taskbar")
               }
           })
       }
    

    I tried this above code but this code is printing console log based on visibility if i minimize the application then it's printing which is wrong

    J 1 Reply Last reply 12 Sept 2023, 15:53
    0
    • P praveen_03
      11 Sept 2023, 10:16

      I'm building one qml application and I printing console log's every where but if I minimize application and try to close from taskbar how will I capture that close event in console log

      Component.onCompleted: {
             Qt.application.activeChanged.connect(function() {
                 if (!Qt.application.active) {
                     console.log("Application closed from taskbar")
                 }
             })
         }
      

      I tried this above code but this code is printing console log based on visibility if i minimize the application then it's printing which is wrong

      J Offline
      J Offline
      JKSH
      Moderators
      wrote on 12 Sept 2023, 15:53 last edited by
      #2

      @praveen_03 said in Qml application closing issue:

      if I minimize application and try to close from taskbar how will I capture that close event in console log

      Try the onClosing signal handler: https://doc.qt.io/Qt-6/qml-qtquick-window.html#closing-signal

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      4
      • D Offline
        D Offline
        dheerendra
        Qt Champions 2022
        wrote on 13 Sept 2023, 04:32 last edited by
        #3

        As suggested by @JKSH Simple sample code to handled the same

               Window {
                    width: 640
                    height: 480
                    visible: true
                    title: qsTr("Hello World")
                    Rectangle{
                        anchors.fill : parent
                        color: "blue"
                        radius : test.val1
                    }
                    onClosing : {
                        console.log("Window is closed")
                    }
                }        
        

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply
        0

        1/3

        11 Sept 2023, 10:16

        • Login

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