KDE 4.9 PyKDE API Reference

- KDE's Python API

# ContainerInterface Class Reference

`from PyKDE4.ktexteditor import *`

Namespace: KTextEditor

## Detailed Description

Class that allows the kpart host to provide some extensions.

The KTextEditor framework allows the kpart host to provide additional services to the kpart. Those services are provided through the ContainerInterface class.

If the container supports those specific services, it should set an instance of the service class with ContainerInterface.setContainer(). That instance should inherit QObject, have the Q_OBJECT macro and declare a Q_INTERFACES(), in order for the qobject_cast mechanism to work.

To obtain a ContainerInterface, in order to set a specific container extension, the kpart host should do:

     // inside the kpart host
     Editor * editor = KTextEditor.EditorChooser.editor();
     ContainerInterface * iface = qobject_cast<ContainerInterface *>( editor );
     if (iface != NULL) {
       iface->setContainer( myContainerExtension );
     } else {
       // the kpart does not support ContainerInterface.
     }

It is then up to the kpart to use it.

## Methods
| __init__ (self)
QObject | container (self)
| setContainer (self, QObject container)

## Method Documentation

__init__ | ( |  | self ) |

Constructor.

QObject container | ( |  | self ) |

Abstract method:
  This method is abstract and can be overridden but not called directly.

Fetch the container extension.

This method is used by the KTextEditor component to know which extensions are supported by the KTextEditor host.

The kpart will cast the result with qobject_cast() to the right container extension to see if that particular extension is supported:

Example:

     // inside the kpart

     Editor * editor = KTextEditor.EditorChooser.editor();
     ContainerInterface * iface = qobject_cast<ConainterInterace *>( editor );
     SomeContainerExtension * myExt =
         qobject_cast<SomeContainerExtension *>( iface->container() );

     if (myExt) {
         // do some stuff with the specific container extension
         // ...
     } else {
         // too bad, that extension is not supported.
     }

\sa setContainer

setContainer | ( | self, |
|  | QObject | container
| ) |  |  |

Abstract method:
  This method is abstract and can be overridden but not called directly.

Set the KTextEditor container.

This method is used by the KTextEditor host to set an instance of a class providing optional container extensions.

\sa container