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. [Solved]closeEvent() is not working when application is closing.

[Solved]closeEvent() is not working when application is closing.

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 5.3k 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.
  • M Offline
    M Offline
    Milnadar
    wrote on last edited by
    #1

    I have a sub class from QmlApplicationViewer in which i override the closeEvent() function, but it is not called when i press the cross on my window. Are there any other ways to catch my application is closing?
    Also tried Component.onDestroying on my root element in QML file, but in this case i think some of children of this item are deleted till that moment.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Milnadar
      wrote on last edited by
      #2

      Perhaps i am doing something wrong?
      @
      class Test : public QWidget
      {
      Q_OBJECT
      public:
      Test(){}
      virtual ~Test(){}
      protected:
      void closeEvent(QCloseEvent *e)
      {
      e->accept();
      }
      };
      @
      There is a break Point in 10 line, but debugger is not stopping on it.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mlong
        wrote on last edited by
        #3

        Depending on what you're trying to do, the "QCoreApplication::aboutToQuit":http://doc.trolltech.com/4.7/qcoreapplication.html#aboutToQuit signal may be helpful.

        EDIT: It's good to use the right class name.

        Software Engineer
        My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          Milnadar
          wrote on last edited by
          #4

          mlong, thank you. QCoreApplication::aboutToQuit helped me.
          Even if i could not find why closeEvent is not working, i find my problem is solved.

          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