More InfoThe kdgantt Advantage
QT Home

Download

Related Products

QicsTable
GraphPak
KDTools


Whitepapers

Advanced Qt Designer Plug-ins
Qt 4's Model/View Delegates
Best Practices in GUI Development
Porting Motif Applications to Qt
Beyond Qtable
Turbocharging Qt Applications
Testing Qt Applications

Gantt Charts in Qt Applications

KD Gantt is a package for creating Gantt charts in Qt applications. It features a large number of configuration options to tailor the Gantt charts to your needs. Since all configuration settings have reasonable defaults you can usually get by with setting only a handful of parameters and relying on the defaults for the rest.

Definition of a Gantt Chart

A Gantt chart is a horizontal bar chart used to schedule and track different tasks in, for example, a software project or a calendar.
It is constructed with a horizontal axis showing the time line that can be divided into several smaller parts, such as hours, days, weeks, etc. A Gantt chart also has a vertical axis containing the different tasks included in the project. These tasks can be sub-items to other tasks or simply stand-alone tasks.

The main widget is separated into two views, the left one containing the tasks, and the other one containing the actual schedule with the time line.

A Gantt chart is often better the more verbose it is. Let us look at an extended KD Gantt Chart, with subtasks as well as task links. You may also configure different types of item.


Extended KD Gantt chart (the first task was changed to a KDGanttViewSummaryItem).

The task links used in the Gantt chart above show dependencies between the tasks. The reason for having a special color on three of the items is basically just for displaying that functionality. This feature can come in handy when you might want to direct the viewer's focus to a certain item.

Overview

Creating a KD Gantt chart

The creation of a Gantt chart is a very easy and straightforward procedure:
  • Create an object of type KDGanttView. This is the actual Gantt view that you later will add different items to. When you want to modify the look of your Gantt chart and its items, you should modify this object, instead of modifying each item individually. This will result in a more uniform look of the Gantt view.
  • Create different objects of KDGanttViewItem. There are three different kinds to choose between: KDGanttViewTaskItem, KDGanttViewSummaryItem, and KDGanttViewEventItem.
You will of course find a detailed description about how to proceed in the programmer's manual, as well as ample sample code.

Items

There are three different items available in KD Gantt: Task, Event, and Summary items, represented by the three classes KDGanttViewTaskItem, KDGanttViewEventItem, and KDGanttViewSummaryItem.


KD Gantt items.

The ability to specify the text that will appear in the list view, as well as the internal name of the item, is available in all constructors.

  • Tasks are used both as a regular schedule item, as well as a Calendar object.
  • Events for scheduling events.
  • Summaries can summarize several tasks into one, having the total time calculated from its children's start/end times.

Customizing items

KDGantt items are highly configurable:
  • Shapes: An item in the Gantt view can have different shapes.

Customize - Shapes.
  • Colors: Different types of items have different default colors. The initial default color is set to blue for event items, green for tasks, and cyan for summaries.
  • Highlight colors: When an item is clicked, it is highlighted. The default color the item is displayed.
  • Start and End time: When a new item is created, its start and end time are set automatically to the current time.

Customize - Start and end time.
  • Priorities: Every item in the Gantt chart has a priority between 1 and 199. On creation time, every item has a default priority of 150.
  • Display modes: There are two different display modes, the "normal" mode and the calendar mode. When the Gantt view is in Calendar mode instead of the "normal" mode, you do not see regular tasks, but rather all tasks belonging to a certain calendar object, on one line.

Customize - Calendar mode.
  • Text and Icons: There are several locations in the Gantt chart where you can have text displayed for an item. These locations include the list view, in the actual chart, as tool-tip text, and as "What's This" text. You can add an icon to a task in KD Gantt. That icon is then displayed next to the text in the list view.

Customize - Texts.
  • Empty tasks: If you want to, you can have all your empty tasks in the Gantt view displayed as a vertical line.
A detailed description and some example codes for those features are available in the programmer's manual.

Task links

A task link is an object of type KDGanttViewTaskLink, containing references to tasks that are linked together. A KDGanttViewTaskLink can link several tasks to several other tasks, several tasks to one task, or just one task to several other tasks.

Grouping Task Links

To uniformly modify several task links at once, you can use KDGanttViewTaskLinkGroup and add several KDGanttViewTaskLink objects to it.
Here we show two of the three different ways of assigning a task link to a task link group. The third way is to use KDGanttViewTaskLink::setGroup() and pass it to the group the task link should belong to.


A highlighted Task Link Group.

Customizing Task Links

  • Color: Changing the color of a task link is done by calling KDGanttViewTaskLink::setColor(), passing the color to use. You may change the color of several task links at once.
  • Highlight Color: When a user clicks on a task link, you may want to display that task link in another color than all the other task links. This is done by highlighting the task link.

Task link colors.
  • Text:T here are a few places in the KD Gantt view where the text of a task link is displayed, including the tool-tip text and the "What's This?" text.
  • Visibility: If, for some reason, you want to change the visibility of a task link, or task link group, that can be achieved easily by calling either KDGanttViewTaskLink::setVisible() or KDGanttViewTaskLinkGroup::setVisible(), and passing either true or false, depending on what kind of behavior you want.
A detailed description and some example codes for those features are available in the programmer's manual.

Legends

Adding an item to a legend is a very simple process. You just use KDGanttView::addLegendItem() and pass it the shape to add, its color, and the legend text to be displayed next to the shape.


Legends.

  • It is possible to add your own widgets to the legend header.
There are several different visibility options for the legend and its associated objects:
  • "Show Legend" button shown or hidden
  • Legend shown or hidden
  • Legend displayed as a dock window or integrated in the widget

Legend dock window.

Time-line

The time line is highly configurable- it consists of two scales, one major (upper) and one minor (lower). When you change the scale of the time line, you change the scale of the minor scale. The major scale is recalculated automatically from the value of the minor scale.

  • Scale: Changing the scale is simply done by calling KDGanttView::setScale(), you can set a limit on the minimum or maximum scale .
  • Appearance: There are several ways in which you can modify the look of the time line.
  • Time interval selection: It is possible to click and drag the mouse on the time line to select a time interval. This can then be used to zoom to the current selection





Different customizable Time line scales.

Menus and Dialogs

A few dialogs and menus are built into KD Gantt. These include a context menu for the time line, a context menu for the Gantt chart itself, and a dialog for viewing/editing the properties of an item, accessible by double-clicking an item.
Enabling the menus and the dialog is as simple as calling one method, or connecting one slot.
  • Time line Menu: The time line context menu is highly customizable. The method KDGanttView::setShowHeaderPopupMenu() enables or disables the context menu.
  • Gantt View Menu: context menu that is popped up when clicking into the Gantt view with the right mouse button. From this menu, it is possible to add new root items, children of an item, or after another item, as well as cutting and pasting items.
  • Item Properties Dialog: The Item Properties dialog is displayed when the user creates a new item using the previously mentioned context menu, or when an item is double-clicked.

Item Properties Dialog.

Drawing and updating

  • In some situations, such as when loading a large amount of items from a file, you do not want the Gantt view to be updated when each item is added, but rather when all items have been added. To enable/disable updating, use KDGanttView::setUpdateEnabled().
  • To improve the readability of the Gantt chart, you may add a brush to be drawn on every second line in the Gantt view.

Brush example.

Customizing

You may customize the following items:
  • Size: Manipulate the size of the components inside the Gantt view.
  • Colors: Modify the colors of the Gantt chart to better fit in with the rest of the program.
  • Columns background colors: Customize the background lines of the Gantt view.
  • Widget background colors: Set the background color of one or more columns (you can change the background color of every part in KD Gantt).

Example of a customized background.
  • Grid: To improve the readability of the chart, a grid is displayed in the Gantt view. You can modify the appearance of the grid.
  • Brushes: You can use brushes in the Gantt view to make it more appealing to the eye.
  • Drag-and-Drop: You can enable or disable drag-and-drop in KD Gantt simply.

Customized Gantt view.

Documentation

KD Gantt is delivered with a Programmer's Manual which will get you started with creating your charts and provides lots of pointers to advanced features. Besides this manual, there are two other documents:
  • Depending on your KD Gantt version, you will find different INSTALL files in the doc directory that explain how to install KD Gantt on your platform or how to build it from sources.
  • KD Gantt comes with an extensive Reference Manual that is generated directly from the source code itself. You should refer to these in conjunction with this Programmer's Manual.


Prefer to talk to a live sales advisor? Call 617.621.0060