The K Desktop Environment

Next Previous Table of Contents

7. The MDI Framework

If you're already familiar with previous versions of KDevelop, you will know that your IDE uses so-called "frameworks" as a starting point of application development. These frameworks by default contain a support for a generic document-view model, but were limited to SDI (Single Document Interface, one window with one view area) model structures. From KDevelop 1.1 on, the application wizard is capable of a lot more than the previous versions: it offers some new project types especially for those developers that want to stay up-to-date with the upcoming KDE 2 as well as for Qt 2.1. One major extension are MDI application frameworks for both, KDE 2 and Qt 2.1. These frameworks differ only in the use of some library functions such as file dialogs or message boxes as well as the used toolbar and statusbar classes - the KDE version uses KDE 2 methods, the Qt version the according Qt functions.

To create the fist step of this tutorial application KScribble, be sure that you have followed the instructions in chapter 2 of this tutorial handbook: setting up KDE 2. If that went all right, nothing can go wrong. If you couldn't set up the KDE 2 libraries, be sure that you have Qt-2.1 installed and set up KDevelop for that at least. You can follow this tutorial by choosing the according Qt framework as well (which has the differences as mentioned above: other method calls for dialogs and GUI components).

7.1 Creating an MDI Framework

Now we will start jumping into development by creating the frame application for KScribble. Start KDevelop and choose "Project"-"New" from the menubar to invoke the application wizard. On the first page, you will be shown a tree of project types. These contain KDE and Qt projects. There, select "KDE 2 MDI" from the KDE section. If you only have Qt 2.1 installed, choose "Qt 2.1 MDI" from the Qt section. Then select "Next", enter "KScribble" as project name and "1.0" as version number. Add your name and email address into the according fields and you're done. Click on the "Create" button and KDevelop will generate our first version of KScribble while you can watch the output in the last page of the wizard. Finally, press "Exit" to return to KDevelop. In the output window you will see an additional message showing that the messages file has been set up for your project, which will be important to translate KScribble into other languages.

7.2 Overview

Now it is important to have an understanding where to find what in the generated sources and where your place as a programmer can be found to make KScribble a unique KDE application.

First of all, in the Classviewer you will see three already created classes, KScribbleApp, KScribbleDoc and KScribbleView. As explained above, each of them has a certain part within the application; the App class builds the main window and coordinates user interaction, the Doc class maintains the documents that an application can manipulate; finally the View class is responsible for user interaction with the child windows and communicates with the document connected to it. This has several consequences: to make a good use of the provided functionality, the programmer is bound to use the given View class. By default, the View inherits QWidget as a minimum requirement, but you're by far not limited to that. But inheriting from another class is not too much work and finally there is also the possibility to use a QMainWindow or KTMainWindow for example as the class to inherit and use another class that manages the view.

In the next chapter we'll continue with extending KScribble to manage it's documents. After that we'll implement the user interaction and you will see the first functionality that is unique to our application: we can draw pictures, load and save them.

Next Previous Table of Contents