Next Previous Contents

3. Quick Start

This section will tell you the steps to create a new class. For a more in depth look at what's going on check out the next section.

3.1 Creating a new model

When you first open up KlassModeler you will see an empty tree view. From the file menu choose new. Now you will see an empty model view. These are the two primary windows that you will use to work with a model. The tree view will show you all your classes, methods, and variables in a tree form, whereas the model view will show you the same info as boxes and lines. The model view shows more info (it includes inheritence and method arguments) whereas the tree view is often easier to navigate.

3.2 Creating a new class

Simply right click in the model view and you will get a menu of options. Choose "New Class" and a box with the words "NewClass" in it will appear. This is the basic view of a class with no member functions or variables. You will also see that the new class has appeared in the tree view.

3.3 Filling the class

You can left double click on the new class in either the model view or the tree view, this will bring up the Class Information dialog. The top edit field is the name of the class. You'll probably want to change this. There are five tabs on this dialog. For creating a new class I find it easier to start at the end with the Misc tab. You will definitely want to fill in the Header File and the HTML file. These determine the path and file for generating header files and HTML docs. Paths are relative to the saved KlassModeler file (*.kml). If you haven't saved the file yet then the paths are relative to the current working directory. You can also specify a full path. Next move to the Documentation tab. This is a free form box for writing all your docs about this class. The next tabs are the Methods and Variables tabs and they both work pretty much the same. For this example go to the Methods tab and clik on Add Method. You will see a new method in the list. In the box below the method list you can directly edit the docs for that method and click on Set Doc to save what you write. You can also move methods around to organize them to your liking with the up and down arrows. You can delete them as well.

3.4 Working with Methods and Variables

With the Class Information dialog still open go to the Methods tab. Again you see your list of new methods. Left double click on a method to open the Method Information dialog. Again your first step is probably to change the method name and the return type. If you're creating a constructor or destructor then simple leave the return type empty. If your return type is something fancy like "const int*" then fill that in. It's free form. Next pick your access type as well as whether or not this is a pure virtual function or a Qt slot or signal. Now you have 3 tabs. The variables tab is a lot like the variables tab in the Class Information dialog, only now you are defining the function arguments. The documentation tab will generate docs for this method. The method body tab is where you can enter code that will be written into your header file. This is best for accessor functions. Notice that whatever you type here will be directly entered into the header with no parsing. So you must include the {} brackets and any carriage returns you may want. When you want to work with your variables (either here as arguments or in class information as member variables) you simply left double click on the variable name. This brings up a variable information dialog that should look pretty self evident by now.

3.5 Working with Enums

On the Misc tab you will also see a section for enums. I figure people don't have to work with these much, so the support is sort of raw, but it does work. Click on Add Enum to add a new one. You will then be prompted for a name, fill that in and press okay. Now when you click on the enum in the list you will see the enum body below. This enum body is the exact text that will be put into your header file, so make sure it's correct. Feel free to change it and set the access type however you want it. When you are done press the Set Enum button! If you don't set the enum you will loose the changes. This is what I mean when I say it's wort of raw :) Also if you need to change the enum name you will have to delete it and create a new one. User friendliness is for wussies.

3.6 Misc

When you close all the dialogs you will be back to the model view and tree view. They will both refresh themselves to show you how your class looks now. In the model view you can see all your new methods and variables as well as access info (the colour square). You can left click and drag to move the classes around. You can zoom in or out by right clicking on the model view (not on a class). You can also delete a class by right clicking on the model view (on the class). You can expand or collapse classes in the tree view, and double clicking on classes, methods, or variables will bring up the same information dialogs you've already seen.


Next Previous Contents