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. App closing itself when should close only QDialog window.
Qt 6.11 is out! See what's new in the release blog

App closing itself when should close only QDialog window.

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 2.8k Views 2 Watching
  • 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.
  • D Offline
    D Offline
    Draqun
    wrote on last edited by
    #1

    Hi.

    I have a strange behavior of my application. This will be simple tray application with few windows. Now app has simple menu. When I click "Add reminder" in my menu then show up dialog window as I expected. Problem is when I click Cancel or close button, then app closing itself not only dialog window. Where is bug in my code?

    I write this application on Ubuntu 16.04 with Qt Creator 3.5.1 with Qt 5.5.1 (default from repository)

    Best regards.
    Draqun

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      It might be the auto close feature
      Try setting
      app.setQuitOnLastWindowClosed(false);
      in main.cpp
      https://forum.qt.io/topic/79266/closing-child-object-causes-parent-to-be-closed/15

      1 Reply Last reply
      2
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Take a look at the Desktop Systray Example. It shows exactly how to handle widgets in the case you are interested in.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1
        • D Offline
          D Offline
          Draqun
          wrote on last edited by
          #4

          https://github.com/Draqun/qt-reminder/blob/master/qt-reminder-gui/createreminderdialog.cpp - I did it well? There no will be problem with memory in situation when I ignore this event in every window?

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Why are you calling the base class implementation and then ignore the event ?

            No, there's no leak, ignoring the event makes is go further up to be handled (or not).

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            D 1 Reply Last reply
            0
            • SGaistS SGaist

              Why are you calling the base class implementation and then ignore the event ?

              No, there's no leak, ignoring the event makes is go further up to be handled (or not).

              D Offline
              D Offline
              Draqun
              wrote on last edited by
              #6

              @SGaist said in App closing itself when should close only QDialog window.:

              Why are you calling the base class implementation and then ignore the event ?

              Because I want close this window without closing app. I should do it in another way?

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Did you took a look at the Desktop Systray Example ? It really implements exactly what you need.

                One of the key part is in the main.cpp file: QApplication::setQuitOnLastWindowClosed(false);

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                2
                • D Offline
                  D Offline
                  Draqun
                  wrote on last edited by
                  #8

                  @SGaist said in App closing itself when should close only QDialog window.:

                  Did you took a look at the Desktop Systray Example ?

                  I didn't analyze example deeply. Thanks for help.

                  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