×
Namespaces

Variants
Actions
(Difference between revisions)

Defining a Qt plug-in interface

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Text replace - "Category:MeeGo" to "Category:MeeGo Harmattan")
hamishwillee (Talk | contribs)
m (Text replace - "<code cpp>" to "<code cpp-qt>")
 
Line 34: Line 34:
  
 
The plug-in interface for all "example plug-ins". The plug-in must implement the {{Icode|virtual sayHello()}} method and the {{Icode|virtual someSlot()}} slot.
 
The plug-in interface for all "example plug-ins". The plug-in must implement the {{Icode|virtual sayHello()}} method and the {{Icode|virtual someSlot()}} slot.
<code cpp>
+
<code cpp-qt>
 
#include <QObject>
 
#include <QObject>
 
#include <QString>
 
#include <QString>

Latest revision as of 04:16, 11 October 2012

Article Metadata
Tested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 3rd Edition, FP1, FP2
S60 5th Edition
Symbian
Article
Keywords: QPluginLoader, Q_DECLARE_INTERFACE, Q_INTERFACES, Q_EXPORT_PLUGIN2
Created: tepaa (20 May 2009)
Last edited: hamishwillee (11 Oct 2012)

Contents

[edit] Overview

Qt applications can be extended with Qt plug-ins, which means that some of the application functionality is implemented as common plug-in libraries loaded into the application memory at runtime. To be extendable, the application has to define a common plug-in interface (exampleplugininterface.h). Note that the application does not see the plug-ins directly but only methods and data that are defined into the interface. The detection and loading of plug-ins is handled using QPluginLoader.

This code snippet demonstrates how to define the lower-level Qt plug-in interface. Implementing the interface and using the plug-in are described in additional snippet articles.

[edit] Header (exampleplugininterface.h)

The plug-in interface for all "example plug-ins". The plug-in must implement the virtual sayHello() method and the virtual someSlot() slot.

#include <QObject>
#include <QString>
 
class ExamplePluginInterface : public QObject
{
public:
virtual ~ExamplePluginInterface() {}
virtual QString sayHello() = 0;
 
public slots:
virtual void someSlot(QString value) = 0;
 
protected: // Common data for the plugins
QString data;
};
 
// This Qt macro associates the given Identifier
// "Forum.Nokia.wiki.pluginsnippet.ExamplePluginInterface/1.0"
// to the interface class called ExamplePluginInterface.
// The Identifier must be unique.
Q_DECLARE_INTERFACE(ExamplePluginInterface,
"Forum.Nokia.wiki.pluginsnippet.ExamplePluginInterface/1.0");

[edit] See also

[edit] Postconditions

The Qt plug-in interface is defined.

This page was last modified on 11 October 2012, at 04:16.
107 page views in the last 30 days.
×