#ifndef ORPHANQMAINWINDOW_H
#define ORPHANQMAINWINDOW_H
#include <QMainWindow>
class OrphanQMainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit OrphanQMainWindow(QWidget *parent = 0);
protected:
void closeEvent(QCloseEvent *event);
void changeEvent(QEvent *event);
};
#endif // ORPHANQMAINWINDOW_H
// OrphanQMainWindow.cpp #include "orphanqmainwindow.h" #include "orphanqtdialog.h" #include <QEvent> #include <QCloseEvent> OrphanQMainWindow::OrphanQMainWindow(QWidget *parent) : QMainWindow(parent) { } void OrphanQMainWindow::closeEvent(QCloseEvent *event) { OrphanQDialog::CloseAll(); event->accept(); } void OrphanQMainWindow::changeEvent(QEvent *event) { QMainWindow::changeEvent(event); if (event->type() != QEvent::WindowStateChange) return; Qt::WindowStates os = static_cast<QWindowStateChangeEvent*>(event)->oldState(); Qt::WindowStates ns = windowState(); if (ns & Qt::WindowMinimized) { OrphanQDialog::MinimizeAll(); } if (os & Qt::WindowMinimized) { OrphanQDialog::RestoreAll(); } }
No comments:
Post a Comment