Qt:Документация 4.3.2/qtplugin

Материал из Wiki.crossplatform.ru

Версия от 09:01, 29 января 2009; Root (Обсуждение | вклад)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск
40px Внимание: Актуальная версия перевода документации находится здесь

__NOTOC__

Image:qt-logo.png

Главная · Все классы · Основные классы · Классы по группам · Модули · Функции

Image:trolltech-logo.png

Содержание

[править] <QtPlugin> - Macros for Defining Plugins

[править] Macros

See also How to Create Qt Plugins.


[править] Macro Documentation

[править]
Q_DECLARE_INTERFACE ( ClassName, Identifier )

This macro associates the given Identifier (a string literal) to the interface class called ClassName. The Identifier must be unique. Пример:

 Q_DECLARE_INTERFACE(BrushInterface,
                     "com.trolltech.PlugAndPaint.BrushInterface/1.0")

This macro is normally used right after the class definition for ClassName, in a header file. See the Plug & Paint example for details.

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. Пример:

 namespace Foo
 {
     struct MyInterface { ... };
 }
 
 Q_DECLARE_INTERFACE(Foo::MyInterface, "org.examples.MyInterface")

See also Q_INTERFACES(), Q_EXPORT_PLUGIN2(), and How to Create Qt Plugins.

[править]
Q_EXPORT_PLUGIN2 ( PluginName, ClassName )

This macro exports the plugin class ClassName for the plugin specified by PluginName. The value of PluginName should correspond to the TARGET specified in the plugin's project file.

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.

Пример:

 Q_EXPORT_PLUGIN2(pnp_extrafilters, ExtraFiltersPlugin)

See the Plug & Paint example for details.

Эта функция была введена в Qt 4.1.

See also Q_DECLARE_INTERFACE() and How to Create Qt Plugins.

[править]
Q_IMPORT_PLUGIN ( PluginName )

This macro imports the plugin named PluginName, corresponding to the TARGET specified in the plugin's project file.

Inserting this macro into your application's source code will allow you to make use of a static plugin.

Пример:

 Q_IMPORT_PLUGIN(qjpeg)

Static plugins must also be included by the linker when your application is built. For Qt's predefined plugins, you can use the QTPLUGIN to add the required plugins to your build. Пример:

 TEMPLATE      = app
 QTPLUGIN     += qjpeg qgif qmng    # image formats

See also Static Plugins, How to Create Qt Plugins, and Using qmake.



Copyright © 2007 Trolltech Trademarks
Qt 4.3.2