Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Creating KParts components, Part 1: Build KParts components

David Faure (faure@kde.org), Maintainer of Konqueror, MandrakeSoft
David Faure is a French KDE Developer working for MandrakeSoft and the maintainer of Konqueror, the file manager and Web browser. He also works on the KDE libraries (component technology and network transparency) and on KOffice (framework and KWord). His experience with KParts stems directly from his involvement in the design and development of KParts, particularly before the KDE 2.0 release. You can contact him at faure@kde.org.

Summary:  This tutorial shows you how to build and deploy a KParts component, how to provide extra functionality through the component's actions, and how to improve integration into Konqueror with the Browser Extension.

View more content in this series

Date:  21 May 2002
Level:  Introductory PDF:  A4 and Letter (92 KB | 19 pages)Get Adobe® Reader®

Activity:  7282 views
Comments:  

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.

Prerequisites

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 the kdesdk package to generate a compilation framework. You can get kdesdk from kde.org (as well as from many other places Web-wide).

Technical terms

  • 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 /usr on many distributions. The best way to check is to run kde-config --prefix.

1 of 8 | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Linux
ArticleID=132914
TutorialTitle=Creating KParts components, Part 1: Build KParts components
publish-date=05212002
author1-email=faure@kde.org
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.