KDE Alkalmazás Tankönyv: Az MDI keretalkalmazás

Következő Előző Tartalom

## 7. Az MDI keretalkalmazás

If you're already familiar with previous versions of KDevelop, you will know that your IDE uses so-called "frameworks" as a startingpoint of application development. These frameworks by default contain a support for a generic document-view model, but were limited toSDI (Single Document Interface, one window with one view area) model structures. From KDevelop 1.1 on, the application wizard iscapable of a lot more than the previous versions: it offers some new project types especially for those developers that want to stayup-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 Qt2.1. These frameworks differ only in the use of some library functions such as file dialogs or message boxes as well as the usedtoolbar 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 2of 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 Qtframework 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. Thesecontain 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 nameand email address into the according fields and you're done. Click on the "Create" button and KDevelop will generate our first versionof KScribble while you can watch the output in the last page of the wizard. Finally, press "Exit" to return to KDevelop. Inthe output window you will see an additional message showing that the messages file has been set up for your project, which will beimportant 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 befound 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 mainwindow and coordinates user interaction, the Doc class maintains the documents that an application can manipulate; finally the Viewclass is responsible for user interaction with the child windows and communicates with the document connected to it. This has severalconsequences: to make a good use of the provided functionality, the programmer is bound to use the given View class. By default, theView inherits `QWidget` as a minimum requirement, but you're by far not limited to that. But inheriting from another class isnot too much work and finally there is also the possibility to use a `QMainWindow` or `KTMainWindow` for example as theclass 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 userinteraction and you will see the first functionality that is unique to our application: we can draw pictures, load and save them.

Következő Előző Tartalom