Hi all,
I am workin on a designer application which i have created by using Qt Mdi app model... When i am creating a new page(work space) and adding it to the MDI area. As a normal MDI app all the sub Windows will be shown at a time in the MDI Area. But i need to show only one subWindow at a time... Whnever i am opening a new page it should close the previous page and open the new one... when i was trying to use this my app get crashed..
void CWindowController :: createWorkspace()
{
Qt::WindowFlags flags;
flags = Qt::Window | Qt::WindowMinimizeButtonHint;
static int pageNumber = 0;
pageNumber++;
newPage = CWidgetFactory::getInstance()->createPage();
newPage->setSize(800,480);
newPage->setAutoFillBackground(true);
newPage->setWidgetName(name);
newPage->setWindowTitle(name);
if(mdiArea->activeSubWindow())
{
mdiArea->activeSubWindow()->close();
}
QMdiSubWindow* subWindow = mdiArea->addSubWindow(newPage,flags);
subWindow->resize(newPage->size());
newPage->show();
}
void CWindowController :: createWorkspace()
{
Qt::WindowFlags flags;
flags = Qt::Window | Qt::WindowMinimizeButtonHint;
static int pageNumber = 0;
pageNumber++;
newPage = CWidgetFactory::getInstance()->createPage();
newPage->setSize(800,480);
newPage->setAutoFillBackground(true);
QString name = QString("Page_%1").arg(pageNumber);
newPage->setWidgetName(name);
newPage->setWindowTitle(name);
if(mdiArea->activeSubWindow())
{
mdiArea->activeSubWindow()->close();
}
QMdiSubWindow* subWindow = mdiArea->addSubWindow(newPage,flags);
subWindow->resize(newPage->size());
newPage->show();
}
To copy to clipboard, switch view to plain text mode
This is the sample code for creating work space.... Is there any other way to implement this... And in my designer i ll be having one project viewer too which will show all the page names in tree view... when i click on a page name, i need to close the current page on the work space and load this new page on to the work space.. any IDEA!!!
Bookmarks