Small tutorial and introduction

This library contains 3 main classes:

  1. an MDI client, a class which inherits qmdiClient
  2. an MDI server, for example qmdiServer
  3. an MDI host, a class which inherits qmdiHost

The MDI host is generally the main window. The MDI server is usually a qmdiTabWidget. The MDI clients are any widget you define, these are the widgets inserted into the MDI server.

When a new client is selected on the MDI server (for example a users selects a new tab), the MDI server (qmdiTabWidget or qmdiWorkspace) will try and merge the menus and toolbars in the MDI client (the widget inside the tab widget) into the MDI host (the main window). The MDI server will also un-merge the last MDI client from the MDI host. It also does a few other things behind the scenes, but you don't have to worry about it.

There are a few steps you should follow to use the library on your application:

  1. Inherit the main window from QMainWindow and qmdiHost.
    class myWindow: public QMainWindow, public qmdiHost
    {
    ...
    };
    

  2. Into the main window, insert a qmdiTabWidget (instead of a normal QTabWidget)
    myWindow *w = new myWindow;
    qmdiTabWidget *tab = new qmdiTabWidget(w);
    w->setCentralWidget( tab );
    

  3. Every widget inserted into the tab widget, must also inherit qmdiClient
    class myWidget: public QWidget, public qmdiClient
    {
    ...
    };
    
    tab->insert( new myWidget );
    

  4. Menus and toolbars (on the main window, and on the MDI clients) must be defined using the qmdiActionGroup widget:
    QAction *fileNew = new QAction( this, "New" );
    
    menus["&File"]->addAction( fileNew );
    toolbars["File"]->addAction( fileNew );
    

  5. After the menu and toolbar allocations (usually at the constructor of the main window), don't forget to call updateGUI:
    myWindow::myWindow( QWidget *parent ):QMainWindow(parent)
    {
            // some initializations
            ...
    
            // generate some QActions
            ...
    
            updateGUI( this );
    }
    

There are some full examples available, please read the code on these examples to get a full examples.

Go to the Main page


Generated on Fri Jun 29 21:56:34 2007 for qmdilib by  doxygen 1.5.1