PDA

View Full Version : Need a Task/Main Window that is neither SDI nor MDI



doberkofler
14th April 2010, 07:04
I'm in the process of migrating a multi-platform application to Qt4 I would need to provide the concept of a "Task Window" (conceptually this might be what Qt calls QMainWindow) as follows:
1) The task window is a visible window that provides an enclosure of all application windows (not on the Macintosh platform where it the task window itself is virtual/invisible and only shows the application menu bar)
2) The task window has the application menu bar and (eventually) a status bar but no toolbar
3) Using the menu bar of the task window the user now opens application windows that will be enclosed in the task window but can also have their own menu bar, toolbar and status bar
4) The task window keeps track of the applications windows and offers a menu showing all open application windows
5) When closing the task window all application windows should be notified and closed (if allowed by the application window)

I'm struggling to understand how to be model this in Qt and it seems as if what I need is somewhere between the concept of MDI and SDI. Any help or comments is appreciated.

spud
14th April 2010, 07:52
What you describe should be possible with a classic QMainWindow/QMDIArea setup. You would then decorate the QMDISubWindows using the classes QToolBar, QStatusBar and QMenuBar. These classes aren't limited to be used with the QMainWindow.

EDIT:
I just realized you can add a QMainWindow to a QMainWindow.
Try the following:

#include <QtGui>

QMainWindow* newWindow(int i=2)
{
QMainWindow* w=new QMainWindow(0,0);
w->menuBar()->addMenu("&File");
QMdiArea* a = new QMdiArea;
w->setCentralWidget(a);
w->statusBar()->showMessage(QString("Level %1").arg(i));
w->addToolBar("")->addAction(new QAction("A", w));
if(i)
a->addSubWindow(newWindow(--i));
return w;
}

int main(int argc, char* argv[])
{
QApplication app(argc, argv);
newWindow()->show();
return app.exec();
}

4501