Qt-interest Archive, August 2007
mdiArea closeallsubwindows
Message 1 in thread
Hi,
when I close an active window, I have no problem to open a new one, but
when I try the QMdiArea::closeAllSubWindows () I am enable to open any
new window in my workspace.
any ideas?
thanks,
marie
here is part of my code
-------------- csbdmainwindow.cpp
CSBDMainWindow::CSBDMainWindow ( QWidget* parent, Qt::WFlags fl )
: QMainWindow ( parent, fl ), Ui::MainWindow()
{
setupUi ( this );//this function is called from the parent
ui_mainwindow.h. It creates the Actions, the Menus, the Toolbars and
sets the title for the window created when using Designer
mdiArea = new QMdiArea;
setCentralWidget ( mdiArea );
//connection of signals and slots
connect ( mdiArea, SIGNAL ( subWindowActivated ( QMdiSubWindow * ) ),
this, SLOT ( updateMenus() ) );
windowMapper = new QSignalMapper ( this );
connect ( windowMapper, SIGNAL ( mapped ( QWidget * ) ),
this, SLOT ( setActiveSubWindow ( QWidget * ) ) );
createConnections();
createStatusBar();
updateMenus();
//readSettings();
}
....
more code and more classes
....
connect ( closeAllWindowAction, SIGNAL ( activated() ),
mdiArea, SLOT ( close () ) );
connect ( closeWindowAction, SIGNAL ( activated() ),
mdiArea, SLOT ( closeActiveSubWindow() ) );
.....
more code and more classes
....
CSBDMdiChild * CSBDMainWindow::createMdiChild()
{
CSBDMdiChild *child = new CSBDMdiChild;
mdiArea->addSubWindow ( child );
return child;
}
-------------------csbdmdichild.cpp
CSBDMdiChild::CSBDMdiChild ( QWidget* parent, Qt::WFlags fl )
: QWidget ( parent, fl ), Ui::Form()
{
setupUi ( this );
CSBDqglviewer = new CSBDQGLViewer();
gridLayout->addWidget ( CSBDqglviewer, 0, 0, 1, 1 );
}
.....
more code and more classes
....
void CSBDMdiChild::closeEvent ( QCloseEvent *event )
{
event->accept();
}
--
[ signature omitted ]
Message 2 in thread
You are not calling QMdiArea::closeAllSubWindows(), you are calling
QMdiArea::close() :
connect ( closeAllWindowAction, SIGNAL ( activated() ),
mdiArea, SLOT ( close () ) );
Close deletes the QMdiArea.
Keith
**Please do not reply to me, reply to the list.**
On 08-15-2007 3:44 PM, "Marie-Christine Vallet" wrote:
> Hi,
>
> when I close an active window, I have no problem to open a new one, but
> when I try the QMdiArea::closeAllSubWindows () I am enable to open any
> new window in my workspace.
> any ideas?
> thanks,
> marie
>
> here is part of my code
> -------------- csbdmainwindow.cpp
> CSBDMainWindow::CSBDMainWindow ( QWidget* parent, Qt::WFlags fl )
> : QMainWindow ( parent, fl ), Ui::MainWindow()
> {
> setupUi ( this );//this function is called from the parent
> ui_mainwindow.h. It creates the Actions, the Menus, the Toolbars and
> sets the title for the window created when using Designer
> mdiArea = new QMdiArea;
> setCentralWidget ( mdiArea );
>
> //connection of signals and slots
> connect ( mdiArea, SIGNAL ( subWindowActivated ( QMdiSubWindow * ) ),
> this, SLOT ( updateMenus() ) );
> windowMapper = new QSignalMapper ( this );
> connect ( windowMapper, SIGNAL ( mapped ( QWidget * ) ),
> this, SLOT ( setActiveSubWindow ( QWidget * ) ) );
>
> createConnections();
> createStatusBar();
> updateMenus();
> //readSettings();
> }
>
> ....
> more code and more classes
> ....
> connect ( closeAllWindowAction, SIGNAL ( activated() ),
> mdiArea, SLOT ( close () ) );
> connect ( closeWindowAction, SIGNAL ( activated() ),
> mdiArea, SLOT ( closeActiveSubWindow() ) );
>
>
> .....
> more code and more classes
> ....
> CSBDMdiChild * CSBDMainWindow::createMdiChild()
> {
> CSBDMdiChild *child = new CSBDMdiChild;
> mdiArea->addSubWindow ( child );
>
>
>
>
> return child;
> }
>
>
>
> -------------------csbdmdichild.cpp
>
>
>
> CSBDMdiChild::CSBDMdiChild ( QWidget* parent, Qt::WFlags fl )
> : QWidget ( parent, fl ), Ui::Form()
> {
> setupUi ( this );
>
>
> CSBDqglviewer = new CSBDQGLViewer();
> gridLayout->addWidget ( CSBDqglviewer, 0, 0, 1, 1 );
>
> }
> .....
> more code and more classes
> ....
> void CSBDMdiChild::closeEvent ( QCloseEvent *event )
> {
>
> event->accept();
> }
--
[ signature omitted ]