Results 1 to 2 of 2

Thread: Close event in QMdiSubWindow

  1. #1
    Join Date
    May 2009
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Close event in QMdiSubWindow

    Hi,
    i have a problem catch the closing event in in subwindow.
    Here is my source code:

    mainwindow.cpp
    Qt Code:
    1. void MainWindow::newMdiChild()
    2. {
    3. qDebug() << "MainWindow::newMdiChild()";
    4.  
    5. tcache.newWindow();
    6. QWidget *widget = new QWidget(ui->mdiArea);
    7. QVBoxLayout *layout = new QVBoxLayout(widget);
    8.  
    9. mdiForm *mForm = new mdiForm(this);
    10. layout->addWidget(mForm);
    11. widget->setLayout(layout);
    12. QMdiSubWindow *subWindow = ui->mdiArea->addSubWindow(widget);
    13. subWindow->resize(600,600);
    14. subWindow->setAttribute(Qt::WA_DeleteOnClose);
    15. subWindow->setWindowTitle("");
    16. subWindow->show();
    17. //...
    18. }
    To copy to clipboard, switch view to plain text mode 
    mdiform.cpp
    Qt Code:
    1. #include "mdiform.h"
    2. #include "ui_mdiform.h"
    3. #include <QtCore/QtDebug>
    4. mdiForm::mdiForm(QWidget *parent) :
    5. QWidget(parent),
    6. m_ui(new Ui::mdiForm)
    7. {
    8. m_ui->setupUi(this);
    9. }
    10. void mdiForm::closeEvent(QCloseEvent *event)
    11. {
    12. qDebug() << "mdiForm::closeEvent()";
    13. }
    14. mdiForm::~mdiForm()
    15. {
    16. delete m_ui;
    17. }
    To copy to clipboard, switch view to plain text mode 
    mdiform.h
    Qt Code:
    1. #ifndef MDIFORM_H
    2. #define MDIFORM_H
    3. #include <QtGui/QWidget>
    4. #include <QtGui/QCloseEvent>
    5. #include "ui_mdiform.h"
    6. namespace Ui {
    7. class mdiForm;
    8. }
    9. class mdiForm : public QWidget {
    10. Q_OBJECT
    11. Q_DISABLE_COPY(mdiForm)
    12. public:
    13. explicit mdiForm(QWidget *parent = 0);
    14. virtual ~mdiForm();
    15. Ui::mdiForm *m_ui;
    16.  
    17. protected:
    18. virtual void closeEvent(QCloseEvent *event);
    19.  
    20. };
    21. #endif // MDIFORM_H
    To copy to clipboard, switch view to plain text mode 
    Can you help me to find a solution for this?
    Last edited by bxaHj; 22nd May 2009 at 09:13.

  2. #2
    Join Date
    Jul 2006
    Location
    Atlanta, GA
    Posts
    86
    Thanks
    26
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Close event in QMdiSubWindow

    Qt Code:
    1. protected:
    2. void closeEvent(QCloseEvent *event);
    To copy to clipboard, switch view to plain text mode 
    If there isn't a difference in what to do when accepted or rejected, just connect them both to a certain slot.
    fnmblot
    --------------------------------------
    Gee Ricky, I'm sorry your mom blew up.

Similar Threads

  1. Replies: 4
    Last Post: 19th February 2009, 11:10
  2. Catching escape event with QMdiSubWindow
    By y.shan in forum Qt Programming
    Replies: 0
    Last Post: 3rd September 2008, 13:02
  3. Close a QMdiSubwindow
    By John_P in forum Qt Programming
    Replies: 4
    Last Post: 14th March 2008, 17:23
  4. Close Event for DialogBased Application.
    By merry in forum Qt Programming
    Replies: 1
    Last Post: 12th December 2007, 12:33
  5. Close event
    By gyre in forum Newbie
    Replies: 3
    Last Post: 20th November 2007, 13:49

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.