About this tutorial
This tutorial shows you how to create KParts components. It introduces the core KParts concepts of read-only and read-write parts and network transparency.
KParts is the component technology that has been introduced in KDE 2. KParts allows KDE applications that need the same functionality to share a component for this task, "embedding" the graphical component into the application's window. KParts components are mainly viewers and editors.
This tutorial presents the classes provided by the
KParts framework: ReadOnlyPart for viewers, and
ReadWritePart for editors. The tutorial then demonstrates
how to create a basic component. The example component can view XML
files as a tree of tags. This example uses the QListView
widget (included in the Qt library).
The tutorial then shows how to deploy the component so that Konqueror can use it, and later the tutorial shows how to add actions to the component, including the XML-GUI file to position those actions in the GUI. Lastly, it demonstrates how to transform a read-only part into a read-write part.
The second KParts tutorial, "Creating KParts components, Part 2: Use KParts components in a KDE application," shows how to write KDE applications that are able to utilize KParts components, either those provided by KDE or custom ones.
Readers should be familiar with C++ application development: classes, methods, members, etc. It's also helpful to have a basic knowledge about Qt, such as signals and slots. Previous experience with KDE development will help in understanding the tutorial, although it isn't required.
To gain an understanding of the KParts component architecture, read the article "Coding with KParts," also by David Faure.
To run the code in this tutorial, you need the following tools:
- KDE 2.x or 3.x and its development packages. KDE 3 is recommended, since it simplifies some of the code needed to use KParts. Download KDE from kde.org.
- A C++ compiler (usually gcc) and other standard GNU programming tools (make, autoconf etc.), which all come with any Linux distribution. You can download gcc from GNU.
- Developers who prefer an IDE instead of a simple text editor can use KDevelop.
- Without
KDevelop, it is necessary to use thekdesdkpackage to generate a compilation framework. You can get kdesdk from kde.org (as well as from many other places Web-wide).
- The tutorial uses the words component and part interchangeably, since a KParts component is called a part.
- The variable $prefix designates the prefix (in other words, base
directory) where KDE is installed. This is
/usron many distributions. The best way to check is to runkde-config --prefix.




