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
QtWS25 Last Chance

Qml application closing issue

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qt 5.4qmlc++
3 Posts 3 Posters 587 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 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

    JKSHJ 1 Reply Last reply
    0
    • P praveen_03

      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

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on 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
      • dheerendraD Offline
        dheerendraD Offline
        dheerendra
        Qt Champions 2022
        wrote on 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

        • Login

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