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. Prevent app (with systray icon) from closing when last window is closed.
Forum Updated to NodeBB v4.3 + New Features

Prevent app (with systray icon) from closing when last window is closed.

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 3.8k Views 1 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.
  • T Offline
    T Offline
    ThaRez
    wrote on last edited by
    #1

    Hello
    I made a small app that has a systray icon from where one can launch windows. My problem is that when I close the last window,
    the application closes as well. How can I prevent this so that the user has to rightclick the tray icon and click quite? (the "quit" isn't the issue, only keeping the app alive) Thanks
    Richard

    1 Reply Last reply
    0
    • A Offline
      A Offline
      AcerExtensa
      wrote on last edited by
      #2

      Reimplement closeEvent of your main widget
      @protected:
      void closeEvent(QCloseEvent *);@

      God is Real unless explicitly declared as Integer.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        AcerExtensa
        wrote on last edited by
        #3

        @void TEST::closeEvent(QCloseEvent * e)
        {
        if(this->should_close)
        e->accept():
        else
        e->ignore();
        }@

        God is Real unless explicitly declared as Integer.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          AcerExtensa
          wrote on last edited by
          #4

          Argh, sorry, havn't read you post exactly :)

          try "this":http://qt-project.org/doc/qt-4.8/qapplication.html#quitOnLastWindowClosed-prop:

          @qApp()->setQuitOnLastWindowClosed(false);@

          God is Real unless explicitly declared as Integer.

          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