Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Modal dialog prevent the calling of closeEvent of the mainWindow
Qt 6.11 is out! See what's new in the release blog

Modal dialog prevent the calling of closeEvent of the mainWindow

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 669 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.
  • SamurayHS Offline
    SamurayHS Offline
    SamurayH
    wrote on last edited by
    #1

    Hi,
    I noticed that the closeEvent which I use to commit some changes and do some clean-up just before shutting down my application, is NOT called while the user kill the process and a modal dialog is shown in the mainWindow (as the parent or not). If the dialog is modeless the closeEvent is called.
    Any suggestions, and thanks for your help!

    "قال رسول الله صلى الله عليه وسلم : " أحب الناس إلى الله أنفعهم للناس

    JonBJ 1 Reply Last reply
    0
    • SamurayHS SamurayH

      Hi,
      I noticed that the closeEvent which I use to commit some changes and do some clean-up just before shutting down my application, is NOT called while the user kill the process and a modal dialog is shown in the mainWindow (as the parent or not). If the dialog is modeless the closeEvent is called.
      Any suggestions, and thanks for your help!

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @SamurayH said in Modal dialog prevent the calling of closeEvent of the mainWindow:

      kill the process

      How does the user kill the process? How can you get a close event at all if you kill the process? Why would you want to commit anything if the process gets killed (at the very most clean up, that should be it)?

      1 Reply Last reply
      1
      • SamurayHS Offline
        SamurayHS Offline
        SamurayH
        wrote on last edited by
        #3

        I can get the closeEvent if the process is killed in the task manager and no modeless dialog is shown. I can't leave without that clean up. I managed right now to disable the window while showing the modeless dialog but it doesn't seem to be a good alternative.

        "قال رسول الله صلى الله عليه وسلم : " أحب الناس إلى الله أنفعهم للناس

        JonBJ 1 Reply Last reply
        0
        • SamurayHS SamurayH

          I can get the closeEvent if the process is killed in the task manager and no modeless dialog is shown. I can't leave without that clean up. I managed right now to disable the window while showing the modeless dialog but it doesn't seem to be a good alternative.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @SamurayH said in Modal dialog prevent the calling of closeEvent of the mainWindow:

          can get the closeEvent if the process is killed in the task manager

          I'm astonished at that. It's probably not very cross-platform, which maybe you don't care about.

          I would never rely on any kind of OS "kill signal" invoking anything like a close event on any widget in your code. And you've seen it isn't reliable if, say, you have some modal dialog up anyway. The correct way is surely to handle the "kill" signal from the OS explicitly via code, and have that share any "clean up" code you may have written for the close event via direct function call without relying on the event itself.

          1 Reply Last reply
          0
          • SamurayHS Offline
            SamurayHS Offline
            SamurayH
            wrote on last edited by
            #5

            Thanks @JonB , I decided to create a crush handler. While the clean up operation is about encrypting some files.., I can call it in an other process, then I'm sure it's called. But thanks anyway.

            "قال رسول الله صلى الله عليه وسلم : " أحب الناس إلى الله أنفعهم للناس

            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