<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <!-- qplugin.qdoc --> <head> <title>Qt 4.6: <QtPlugin> - Macros for Defining Plugins</title> <link href="classic.css" rel="stylesheet" type="text/css" /> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td> <td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="functions.html"><font color="#004faf">All Functions</font></a> · <a href="overviews.html"><font color="#004faf">Overviews</font></a></td></tr></table><h1 class="title"><QtPlugin> - Macros for Defining Plugins<br /><span class="subtitle"></span> </h1> <p>The <<a href="qmake-variable-reference.html#qtplugin">QtPlugin</a>> header files defines macros for defining plugins. <a href="#details">More...</a></p> <ul> <li><a href="qtplugin-obsolete.html">Obsolete members</a></li> </ul> <a name="Macrosx"></a> <h2>Macros</h2> <table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qtplugin.html#Q_DECLARE_INTERFACE">Q_DECLARE_INTERFACE</a></b> ( <i>ClassName</i>, <i>Identifier</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qtplugin.html#Q_EXPORT_PLUGIN2">Q_EXPORT_PLUGIN2</a></b> ( <i>PluginName</i>, <i>ClassName</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qtplugin.html#Q_IMPORT_PLUGIN">Q_IMPORT_PLUGIN</a></b> ( <i>PluginName</i> )</td></tr> </table> <p>See also <a href="plugins-howto.html">How to Create Qt Plugins</a>.</p> <hr /> <h2>Macro Documentation</h2> <a name="//apple_ref/cpp/macro//Q_DECLARE_INTERFACE"></a> <h3 class="fn"><a name="Q_DECLARE_INTERFACE"></a>Q_DECLARE_INTERFACE ( <i>ClassName</i>, <i>Identifier</i> )</h3> <p>This macro associates the given <i>Identifier</i> (a string literal) to the interface class called <i>ClassName</i>. The <i>Identifier</i> must be unique. For example:</p> <pre> Q_DECLARE_INTERFACE(BrushInterface, "com.trolltech.PlugAndPaint.BrushInterface/1.0")</pre> <p>This macro is normally used right after the class definition for <i>ClassName</i>, in a header file. See the <a href="tools-plugandpaint.html">Plug & Paint</a> example for details.</p> <p>If you want to use Q_DECLARE_INTERFACE with interface classes declared in a namespace then you have to make sure the Q_DECLARE_INTERFACE is not inside a namespace though. For example:</p> <pre> namespace Foo { struct MyInterface { ... }; } Q_DECLARE_INTERFACE(Foo::MyInterface, "org.examples.MyInterface")</pre> <p>See also <a href="qobject.html#Q_INTERFACES">Q_INTERFACES</a>(), <a href="qtplugin.html#Q_EXPORT_PLUGIN2">Q_EXPORT_PLUGIN2</a>(), and <a href="plugins-howto.html">How to Create Qt Plugins</a>.</p> <a name="//apple_ref/cpp/macro//Q_EXPORT_PLUGIN2"></a> <h3 class="fn"><a name="Q_EXPORT_PLUGIN2"></a>Q_EXPORT_PLUGIN2 ( <i>PluginName</i>, <i>ClassName</i> )</h3> <a name="q-export-plugin2"></a><p>This macro exports the plugin class <i>ClassName</i> for the plugin specified by <i>PluginName</i>. The value of <i>PluginName</i> should correspond to the <a href="qmake-variable-reference.html#target">TARGET</a> specified in the plugin's project file.</p> <p>There should be exactly one occurrence of this macro in the source code for a Qt plugin, and it should be used where the implementation is written rather than in a header file.</p> <p>Example:</p> <pre> Q_EXPORT_PLUGIN2(pnp_extrafilters, ExtraFiltersPlugin)</pre> <p>See the <a href="tools-plugandpaint.html">Plug & Paint</a> example for details.</p> <p>This function was introduced in Qt 4.1.</p> <p>See also <a href="qtplugin.html#Q_DECLARE_INTERFACE">Q_DECLARE_INTERFACE</a>() and <a href="plugins-howto.html">How to Create Qt Plugins</a>.</p> <a name="//apple_ref/cpp/macro//Q_IMPORT_PLUGIN"></a> <h3 class="fn"><a name="Q_IMPORT_PLUGIN"></a>Q_IMPORT_PLUGIN ( <i>PluginName</i> )</h3> <p>This macro imports the plugin named <i>PluginName</i>, corresponding to the <a href="qmake-variable-reference.html#target">TARGET</a> specified in the plugin's project file.</p> <p>Inserting this macro into your application's source code will allow you to make use of a static plugin.</p> <p>Example:</p> <pre> Q_IMPORT_PLUGIN(qjpeg)</pre> <p>Static plugins must also be included by the linker when your application is built. For Qt's predefined plugins, you can use the <tt>QTPLUGIN</tt> to add the required plugins to your build. For example:</p> <pre> TEMPLATE = app QTPLUGIN += qjpeg qgif qmng # image formats</pre> <p>See also <a href="plugins-howto.html#static-plugins">Static Plugins</a>, <a href="plugins-howto.html">How to Create Qt Plugins</a>, and <a href="qmake-using.html">Using qmake</a>.</p> <p /><address><hr /><div align="center"> <table width="100%" cellspacing="0" border="0"><tr class="address"> <td width="40%" align="left">Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)</td> <td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td> <td width="40%" align="right"><div align="right">Qt 4.6.3</div></td> </tr></table></div></address></body> </html>