_Mithrandir_
22nd May 2012, 09:52
Hi all,
I need to build an application in which several forms open one over the other. To avoid having many floating windows cluttering up the user's screen, I have thought of realizing a dynamic stack of QWidget(s) (derived from a custom abstract class StackableWidget).
Unfortunately this solution isn't working. When I try to retrieve the old QWidget from the stack I get an invalid reference. In the watch windows of QtCreator it says <unavailable synchronous data>, but I'm not (explicitly) using threads.
void MyMainWindow::pushWidget(StackableWidget *widget)
{
StackableWidget *sw = dynamic_cast<StackableWidget *>(this->centralWidget());
m_stack.prepend(sw);
sw->hide();
this->setCentralWidget(widget);
QObject::connect(widget, SIGNAL(closed()), this, SLOT(childClosed()));
}
void MyMainWindow::childClosed()
{
StackableWidget *current = dynamic_cast<StackableWidget *>(this->centralWidget());
current->hide();
StackableWidget *old = m_stack.takeFirst();
this->setCentralWidget(old);
delete current;
old->updateData();
}
I'm pretty a noob with Qt, so please be gentle. Thanks in advance for your help!
I need to build an application in which several forms open one over the other. To avoid having many floating windows cluttering up the user's screen, I have thought of realizing a dynamic stack of QWidget(s) (derived from a custom abstract class StackableWidget).
Unfortunately this solution isn't working. When I try to retrieve the old QWidget from the stack I get an invalid reference. In the watch windows of QtCreator it says <unavailable synchronous data>, but I'm not (explicitly) using threads.
void MyMainWindow::pushWidget(StackableWidget *widget)
{
StackableWidget *sw = dynamic_cast<StackableWidget *>(this->centralWidget());
m_stack.prepend(sw);
sw->hide();
this->setCentralWidget(widget);
QObject::connect(widget, SIGNAL(closed()), this, SLOT(childClosed()));
}
void MyMainWindow::childClosed()
{
StackableWidget *current = dynamic_cast<StackableWidget *>(this->centralWidget());
current->hide();
StackableWidget *old = m_stack.takeFirst();
this->setCentralWidget(old);
delete current;
old->updateData();
}
I'm pretty a noob with Qt, so please be gentle. Thanks in advance for your help!