Qt-interest Archive, June 2007
Problems with QMainSubWindow close
Message 1 in thread
Hi guys,I am developing an application MDI with QT4.3.0. I am with problems in closing the window that is inside of workspace. This window that is in workspace, including a QPushButton that to the set in event being would have to close the window. What it occurs is that it closes (widget that it belongs), but does not close the QMdiSubWindow, being the open window father.It follows stretch of the code of the MainWindow for agreement:[...]mdiArea = new QMdiArea;setCentralWidget(mdiArea);[...]AlterarSenha *win = new AlterarSenha;QMdiSubWindow *currentWindow = new QMdiSubWindow;currentWindow->setWidget(win);currentWindow->setAttribute(Qt::WA_DeleteOnClose);mdiArea->addSubWindow(currentWindow);currentWindow->show( );[...]They observe that the win pointer (AlterarSenha class) is one widget that was created with designer. I use setWidget to place this widget “inside” of the QMdiSubWindow. As I mentioned, when click in the button to close (QPushButton) of the AlterarSenha, this widget if closes, but not it window father (QMdiSubWindow). What to make? This way code is correct?thanks,Marcelo Estanislau.
_________________________________________________________________
Receba as últimas notícias do Brasil e do mundo direto no seu Messenger com Alertas MSN! É GRÁTIS!
http://alertas.br.msn.com/
Message 2 in thread
Hi Marcelo,
> [...]
>
> mdiArea = new QMdiArea;
> setCentralWidget(mdiArea);
>
> [...]
>
> AlterarSenha *win = new AlterarSenha;
> QMdiSubWindow *currentWindow = new QMdiSubWindow;
> currentWindow->setWidget(win);
> currentWindow->setAttribute(Qt::WA_DeleteOnClose);
> mdiArea->addSubWindow(currentWindow);
> currentWindow->show( );
>
> [...]
>
> They observe that the win pointer (AlterarSenha class) is one widget
> that was created with designer. I use setWidget to place this widget
> “inside” of the QMdiSubWindow. As I mentioned, when click in the button
> to close (QPushButton) of the AlterarSenha, this widget if closes, but
> not it window father (QMdiSubWindow). What to make? This way code is
> correct?
>
If you want to close the sub-window itself, you must call close on that
window and not the push button. This behavior is consistent to all other
widgets in Qt.
Just think of QMdiSubWindow and the widget inside it as a regular
QWidget with another QWidget as child. The behavior is almost the same.
--
[ signature omitted ]