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 2: Use KParts components in a KDE application

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 use KParts components in a KDE application. You learn how to use the KDE Trader to locate the appropriate component, how to handle user interface merging, and how to embed multiple parts in the same window with the help of the Part Manager.

View more content in this series

Date:  11 Jun 2002
Level:  Introductory PDF:  A4 and Letter (150 KB | 18 pages)Get Adobe® Reader®

Activity:  6442 views
Comments:  

About this tutorial

This tutorial explains how to use KParts components in a KDE application. It first shows how to create a KParts-enabled main window, then how to define its GUI with XML, and finally how to locate and create the appropriate ReadOnlyPart for a given MIME type. The tutorial then shows how to host multiple parts in the same main window, and how to use a KParts PartManager to handle part activation to update the GUI when switching parts.

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.

The tutorial is divided into three sections that detail the construction of a "universal viewer" capable of displaying any kind of data:

  • Creating a KParts-enabled window
  • Merging the user interface
  • Locating the installed KParts components

The tutorial extends the viewer by showing how to use multiple parts in the same window.

The previous tutorial, "Creating KParts components, Part 1: Build KParts components", shows how to write KDE components and how to make them available to other applications.

Prerequisites

Readers should be familiar with C++ application development and with Qt's basic concepts. (See Resources for links to comprehensive references.) Previous experience with KDE development will help in following the tutorial, although it isn't a requirement. Working through the previous KParts tutorial, "Creating KParts components, Part 1: Build KParts components", is also highly recommended as preparation for this tutorial.

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 7 | 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=132917
TutorialTitle=Creating KParts components, Part 2: Use KParts components in a KDE application
publish-date=06112002
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.