Skip to main content

Create a Simple HMI Plugin

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

1. Get the Development Package

  • Get the ROKAE+ Client Plugin development package (headers, libraries, and examples) from RokaeRobot/xCorePlugin-client.
  • For official download channels, clone steps, and version notes, see Download.

2. Project Configuration (.pro)

  • Create a new project in Qt Creator.
  • Copy the include and lib folders from the Rokae+ development package to the same directory as the project .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 configuration 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);
}

Key points:

  • XPLUGIN_REGISTER(PLUGIN_NAME, MyPlugin) — the macro calls into the xplugin namespace, so MyPlugin must be defined under the xplugin namespace.
  • PLUGIN_NAME — the plugin name identifier in the .pro file.

4. Build and Deploy

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

5. Next Steps