Let Qt keep track of top-level windows.

This commit is contained in:
Jim Evins
2016-05-15 16:33:02 -04:00
parent 1819a02d50
commit f920965668
3 changed files with 5 additions and 23 deletions
+4 -1
View File
@@ -204,8 +204,11 @@ void File::close( MainWindow *window )
/// ///
void File::exit() void File::exit()
{ {
foreach ( MainWindow* window, MainWindow::windowList() ) foreach ( QWidget* qwidget, QApplication::topLevelWidgets() )
{
if ( MainWindow* window = qobject_cast<MainWindow*>(qwidget) )
{ {
window->close(); window->close();
} }
}
} }
-17
View File
@@ -52,12 +52,6 @@
#include "Help.h" #include "Help.h"
///
/// Static window list
///
QList<MainWindow*> MainWindow::smWindowList;
/// ///
/// Constructor /// Constructor
/// ///
@@ -146,8 +140,6 @@ MainWindow::MainWindow()
#endif #endif
readSettings(); readSettings();
smWindowList.push_back( this );
} }
@@ -156,7 +148,6 @@ MainWindow::MainWindow()
/// ///
MainWindow::~MainWindow() MainWindow::~MainWindow()
{ {
smWindowList.removeOne( this );
} }
@@ -208,14 +199,6 @@ bool MainWindow::isEmpty() const
return mModel == 0; return mModel == 0;
} }
///
/// Get window list
///
QList<MainWindow*> MainWindow::windowList()
{
return smWindowList;
}
/// ///
/// Close Event Handler /// Close Event Handler
-4
View File
@@ -70,8 +70,6 @@ public:
void setModel( LabelModel* label ); void setModel( LabelModel* label );
bool isEmpty() const; bool isEmpty() const;
static QList<MainWindow *> windowList();
///////////////////////////////////// /////////////////////////////////////
// Events // Events
@@ -186,8 +184,6 @@ private:
// Private Data // Private Data
///////////////////////////////////// /////////////////////////////////////
private: private:
static QList<MainWindow*> smWindowList;
QMenu* fileMenu; QMenu* fileMenu;
QMenu* editMenu; QMenu* editMenu;
QMenu* viewMenu; QMenu* viewMenu;