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. close one window close others

close one window close others

Scheduled Pinned Locked Moved Solved General and Desktop
20 Posts 4 Posters 2.8k 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.
  • S saber

    @jsulm

    but other two closes it's window .
    

    that behaviour is good .but why the coreaction is closing it's framless window also the other two window.?

    jsulmJ Online
    jsulmJ Online
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #6

    @saber Can you show your coreaction header file?

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    S 1 Reply Last reply
    0
    • jsulmJ jsulm

      @saber Can you show your coreaction header file?

      S Offline
      S Offline
      saber
      wrote on last edited by saber
      #7

      @jsulm

      /*
      CoreBox is combination of some common desktop apps.
      
      CoreBox is free software; you can redistribute it and/or
      modify it under the terms of the GNU General Public License
      as published by the Free Software Foundation; version 2
      of the License.
      
      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU General Public License for more details.
      
      You should have received a copy of the GNU General Public License
      along with this program; if not, see {http://www.gnu.org/licenses/}. */
      
      #ifndef COREACTION_H
      #define COREACTION_H
      
      #include "wcalender.h"
      #include "wsystem.h"
      #include "wnetwork.h"
      #include "wcalculator.h"
      #include "wnotes.h"
      #include "wbattery.h"
      
      #include <QWidget>
      #include <QFocusEvent>
      #include <QCloseEvent>
      #include <QDir>
      #include <QMenu>
      #include <QSystemTrayIcon>
      #include <QTimer>
      #include <QDesktopWidget>
      #include <QDateTime>
      #include <QTimer>
      #include <QFile>
      #include <QDoubleValidator>
      
      #include "settings/settingsmanage.h"
      #include "utilities/globalfunctions.h"
      #include "about/about.h"
      #include "dashboard/info_manager.h"
      #include "dashboard/upower.h"
      #include "dashboard/battery.h"
      #include "coreshot/coreshotdialog.h"
      
      
      namespace Ui {
      class coreaction;
      }
      
      class coreaction : public QWidget
      {
          Q_OBJECT
      
      public:
          explicit coreaction(QWidget *parent = nullptr);
          ~coreaction();
      
          QSystemTrayIcon *trayIcon;
          void focusOutEvent(QFocusEvent *event);
          void loadsettings();
      
      protected:
          void closeEvent(QCloseEvent *event);
      
      private:
          Ui::coreaction *ui;
          SettingsManage sm;
          QMenu *trayIconMenu;
          QDir currentDir;
          QTimer *timer;
          InfoManager *im;
      
          void widget();
          void tryicon();
          void widgetList();
          bool checkWTime();
          bool checkWCalendar();
          bool checkWSystem();
          bool checkWNetwork();
          bool checkWCalculator();
          bool checkWNotes();
          bool checkWBattery();
      
      public slots:
          void ShowWindow(QSystemTrayIcon::ActivationReason Reason);
      
      private slots:
          void showTime();
          void coreBoxAbout();
          void actionshow();
          void on_corepad_clicked();
          void on_screenshot_clicked();
          void on_corepaint_clicked();
          void on_corefm_clicked();
          void on_start_clicked();
          void on_search_clicked();
      
      };
      
      #endif // COREACTION_H
      
      
      jsulmJ 1 Reply Last reply
      0
      • S saber

        @jsulm

        /*
        CoreBox is combination of some common desktop apps.
        
        CoreBox is free software; you can redistribute it and/or
        modify it under the terms of the GNU General Public License
        as published by the Free Software Foundation; version 2
        of the License.
        
        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.
        
        You should have received a copy of the GNU General Public License
        along with this program; if not, see {http://www.gnu.org/licenses/}. */
        
        #ifndef COREACTION_H
        #define COREACTION_H
        
        #include "wcalender.h"
        #include "wsystem.h"
        #include "wnetwork.h"
        #include "wcalculator.h"
        #include "wnotes.h"
        #include "wbattery.h"
        
        #include <QWidget>
        #include <QFocusEvent>
        #include <QCloseEvent>
        #include <QDir>
        #include <QMenu>
        #include <QSystemTrayIcon>
        #include <QTimer>
        #include <QDesktopWidget>
        #include <QDateTime>
        #include <QTimer>
        #include <QFile>
        #include <QDoubleValidator>
        
        #include "settings/settingsmanage.h"
        #include "utilities/globalfunctions.h"
        #include "about/about.h"
        #include "dashboard/info_manager.h"
        #include "dashboard/upower.h"
        #include "dashboard/battery.h"
        #include "coreshot/coreshotdialog.h"
        
        
        namespace Ui {
        class coreaction;
        }
        
        class coreaction : public QWidget
        {
            Q_OBJECT
        
        public:
            explicit coreaction(QWidget *parent = nullptr);
            ~coreaction();
        
            QSystemTrayIcon *trayIcon;
            void focusOutEvent(QFocusEvent *event);
            void loadsettings();
        
        protected:
            void closeEvent(QCloseEvent *event);
        
        private:
            Ui::coreaction *ui;
            SettingsManage sm;
            QMenu *trayIconMenu;
            QDir currentDir;
            QTimer *timer;
            InfoManager *im;
        
            void widget();
            void tryicon();
            void widgetList();
            bool checkWTime();
            bool checkWCalendar();
            bool checkWSystem();
            bool checkWNetwork();
            bool checkWCalculator();
            bool checkWNotes();
            bool checkWBattery();
        
        public slots:
            void ShowWindow(QSystemTrayIcon::ActivationReason Reason);
        
        private slots:
            void showTime();
            void coreBoxAbout();
            void actionshow();
            void on_corepad_clicked();
            void on_screenshot_clicked();
            void on_corepaint_clicked();
            void on_corefm_clicked();
            void on_start_clicked();
            void on_search_clicked();
        
        };
        
        #endif // COREACTION_H
        
        
        jsulmJ Online
        jsulmJ Online
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #8

        @saber Are the other two windows visible when you close coreaction?
        See http://doc.qt.io/qt-5/qguiapplication.html#quitOnLastWindowClosed-prop
        "If this property is true, the applications quits when the last visible primary window (i.e. window with no parent) is closed."
        Also do you do anything special in closeEvent?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        S 1 Reply Last reply
        0
        • jsulmJ jsulm

          @saber Are the other two windows visible when you close coreaction?
          See http://doc.qt.io/qt-5/qguiapplication.html#quitOnLastWindowClosed-prop
          "If this property is true, the applications quits when the last visible primary window (i.e. window with no parent) is closed."
          Also do you do anything special in closeEvent?

          S Offline
          S Offline
          saber
          wrote on last edited by
          #9

          @jsulm
          when i close the coreaction , the appliction output tab in qt creator shows exited with code 0. so that means other two window is also closed.

          i used that in the main file.you can see that main file in top of this topic.

          yes .i every widow have a close event and that event collect the file path.

          mrjjM 1 Reply Last reply
          0
          • S saber

            @jsulm
            when i close the coreaction , the appliction output tab in qt creator shows exited with code 0. so that means other two window is also closed.

            i used that in the main file.you can see that main file in top of this topic.

            yes .i every widow have a close event and that event collect the file path.

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #10

            @saber

            Very important question. ( as @jsulm asks)
            is
            Start s and/or corefm a;
            shown on screen when u close coreaction ?

            S 1 Reply Last reply
            0
            • mrjjM mrjj

              @saber

              Very important question. ( as @jsulm asks)
              is
              Start s and/or corefm a;
              shown on screen when u close coreaction ?

              S Offline
              S Offline
              saber
              wrote on last edited by
              #11

              @mrjj
              yes. i also tried by minimize corefm and start and then close the coreaction. same result.

              i just want to close all the window independently. close button will close ir's window,no other.

              mrjjM 1 Reply Last reply
              0
              • S saber

                @mrjj
                yes. i also tried by minimize corefm and start and then close the coreaction. same result.

                i just want to close all the window independently. close button will close ir's window,no other.

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #12

                @saber
                They are not closing each other.
                Read link @jsulm gave for info.

                Seems that App thinks coreaction was last and closes app.

                S 1 Reply Last reply
                0
                • mrjjM mrjj

                  @saber
                  They are not closing each other.
                  Read link @jsulm gave for info.

                  Seems that App thinks coreaction was last and closes app.

                  S Offline
                  S Offline
                  saber
                  wrote on last edited by
                  #13

                  @mrjj
                  i read the link .and i also tried the setQuitOnLastWindowClosed(false); .same

                  so what can i do ?

                  mrjjM 1 Reply Last reply
                  0
                  • S saber

                    @mrjj
                    i read the link .and i also tried the setQuitOnLastWindowClosed(false); .same

                    so what can i do ?

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #14

                    @saber
                    Well, you must find out why.
                    Since doing this

                    
                    
                    int main(int argc, char *argv[])
                    {
                        QApplication app(argc, argv);
                    
                        QWidget a;
                        a.show();
                    
                        QWidget b;
                        b.show();
                    
                        QWidget c;
                        c.show();
                    
                        //    MainWindow w;
                        //    w.show();   
                    
                        return app.exec();
                    }
                    
                    

                    Do not close at all. windows are stacked on top of each other.
                    So that means most likely that something in the project code does something.

                    Use debugger and see what is going on. please breakpoint in any closeEvent for coreaction.

                    S 1 Reply Last reply
                    0
                    • mrjjM mrjj

                      @saber
                      Well, you must find out why.
                      Since doing this

                      
                      
                      int main(int argc, char *argv[])
                      {
                          QApplication app(argc, argv);
                      
                          QWidget a;
                          a.show();
                      
                          QWidget b;
                          b.show();
                      
                          QWidget c;
                          c.show();
                      
                          //    MainWindow w;
                          //    w.show();   
                      
                          return app.exec();
                      }
                      
                      

                      Do not close at all. windows are stacked on top of each other.
                      So that means most likely that something in the project code does something.

                      Use debugger and see what is going on. please breakpoint in any closeEvent for coreaction.

                      S Offline
                      S Offline
                      saber
                      wrote on last edited by saber
                      #15

                      @mrjj
                      just asking, dubugg the closeevent?

                      also there is no closeEvent in coreaction.

                      mrjjM 1 Reply Last reply
                      0
                      • S saber

                        @mrjj
                        just asking, dubugg the closeevent?

                        also there is no closeEvent in coreaction.

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #16

                        @saber
                        Then set break point somewhere else :)
                        Like destructor.
                        Something must happen in code.
                        as default sample do NOT close all 3 windows.
                        and its very easy to see what is going on with the call stack so
                        you just need to beak it somewhere and see what is going on.

                        S 1 Reply Last reply
                        2
                        • mrjjM mrjj

                          @saber
                          Then set break point somewhere else :)
                          Like destructor.
                          Something must happen in code.
                          as default sample do NOT close all 3 windows.
                          and its very easy to see what is going on with the call stack so
                          you just need to beak it somewhere and see what is going on.

                          S Offline
                          S Offline
                          saber
                          wrote on last edited by saber
                          #17

                          @mrjj
                          ok . i try to debug.
                          but one thought in my mind.
                          i think window with tray icon with fremless is the cause?
                          also the close mathod

                          QAction *QAquit=new QAction("&Quit",this);
                          connect(QAquit, SIGNAL(triggered()),qApp,SLOT(close()));
                          
                          jsulmJ 1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            saber
                            wrote on last edited by
                            #18

                            i got the problem .
                            i am calling the qApp to close .that's the cause.

                            AbrarA 1 Reply Last reply
                            1
                            • S saber

                              i got the problem .
                              i am calling the qApp to close .that's the cause.

                              AbrarA Offline
                              AbrarA Offline
                              Abrar
                              wrote on last edited by
                              #19

                              @saber this looks really funny...
                              Don't mind.

                              1 Reply Last reply
                              0
                              • S saber

                                @mrjj
                                ok . i try to debug.
                                but one thought in my mind.
                                i think window with tray icon with fremless is the cause?
                                also the close mathod

                                QAction *QAquit=new QAction("&Quit",this);
                                connect(QAquit, SIGNAL(triggered()),qApp,SLOT(close()));
                                
                                jsulmJ Online
                                jsulmJ Online
                                jsulm
                                Lifetime Qt Champion
                                wrote on last edited by
                                #20

                                @saber said in close one window close others:

                                connect(QAquit, SIGNAL(triggered()),qApp,SLOT(close()));

                                Didn't realise it's qApp there :-)
                                Sometimes it is something really small/simple and is hard to see.

                                https://forum.qt.io/topic/113070/qt-code-of-conduct

                                1 Reply Last reply
                                3

                                • Login

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