diff options
| author | Lincoln Ramsay <lincoln.ramsay@nokia.com> | 2010-03-08 13:42:18 +1000 |
|---|---|---|
| committer | Lincoln Ramsay <lincoln.ramsay@nokia.com> | 2010-03-08 13:42:56 +1000 |
| commit | 98a5e032e94ba77bb67a615e2042462b5e6f2923 (patch) | |
| tree | 2a344b2d3d08bbc77d4b5ac3228b7c65a89bb1d3 /doc/src/snippets/sensors/plugin.cpp | |
| parent | ac758f6ec4667e22e62be4dd6a25975112abc972 (diff) | |
replace \code blocks with \snippet statements.
This will let the compiler notify us when our example snippets are
no longer valid.
Diffstat (limited to 'doc/src/snippets/sensors/plugin.cpp')
| -rw-r--r-- | doc/src/snippets/sensors/plugin.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/doc/src/snippets/sensors/plugin.cpp b/doc/src/snippets/sensors/plugin.cpp new file mode 100644 index 0000000000..a4855659ca --- /dev/null +++ b/doc/src/snippets/sensors/plugin.cpp @@ -0,0 +1,28 @@ +#include "mybackend.h" +#include <qsensorplugin.h> +#include <qsensormanager.h> + +const char *MyBackend::id = "mybackend"; + +//! [Plugin] +class MyPluginClass : public QObject, QSensorPluginInterface, public QSensorBackendFactory +{ + Q_OBJECT + Q_INTERFACES(QtMobility::QSensorPluginInterface) +public: + void registerSensors() + { + QSensorManager::registerBackend(QAccelerometer::type, MyBackend::id, this); + } + + QSensorBackend *createBackend(QSensor *sensor) + { + if (sensor->identifier() == MyBackend::id) + return new MyBackend(sensor); + return 0; + } +}; +//! [Plugin] + +//Q_EXPORT_PLUGIN2(libmy_plugin_file_name, MyPluginClass); +#include "plugin.moc" |
