Skip to main content

Create a Simple HMI Plugin

The following uses Windows + Qt Creator as an example; Linux steps are the same, linking against xplugin.so.

1. Obtain the Development Package

  • Download the ROKAE+ development package from the Rokae website.

2. Project Configuration (.pro)

  • Create a new project in Qt Creator.
  • Copy the include and lib folders from the ROKAE+ development package into the same directory as the .pro file.
QT += widgets
CONFIG += c++11 plugin no_plugin_name_prefix
TEMPLATE = lib

DEFINES += PLUGIN_NAME=\\\"MyPlugin\\\"
# Enable log module
DEFINES += LOG_MIN_FILE_LEVEL=XPLUGIN_LOG_LEVEL_DEBUG

INCLUDEPATH += $$PWD/include

LIBS += -L$$PWD/lib/windows -lxplugin
# Use this on ARM:
#LIBS += -L$$PWD/lib/aarch64 -l:xplugin.so

HEADERS += myplugin.h
SOURCES += myplugin.cpp

3. Plugin Class and Registration

// myplugin.h
#include "plugincommon.h"
#include "interface/interfacemanager.h"

namespace xplugin {
class MyPlugin : public PluginBase {
Q_OBJECT
public:
explicit MyPlugin(QObject *parent = nullptr) : PluginBase(parent) {
setPluginLabel(tr("My Plugin"));
}
void init() override;
void detach() override;
};
}

// myplugin.cpp
#include "myplugin.h"
#include "event/xplugineventsystem.h"

XPLUGIN_REGISTER(PLUGIN_NAME, MyPlugin)

void xplugin::MyPlugin::init() {
xPluginInterface().initEventSystem();
auto *w = new QWidget;
CreateCenterWidget(PLUGIN_NAME, w);
}

void xplugin::MyPlugin::detach() {
xPluginEvent().unsubscribeByPlugin(PLUGIN_NAME);
}

Notes:

  • XPLUGIN_REGISTER(PLUGIN_NAME, MyPlugin) - the macro uses the xplugin namespace, so MyPlugin must be defined in namespace xplugin.
  • PLUGIN_NAME is the plugin identifier in the .pro file.

4. Build and Deploy

  • Build to obtain MyPlugin.dll or MyPlugin.so (on ARM).
  • Package the plugin according to Configuration Format.

5. Next Steps