Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

New_plugin_from_scratch

Paweł Salawa edited this page May 8, 2026 · 3 revisions

Table of Contents

Brief

This tutorial covers creating plugins using QtCreator. Under Windows it's QtCreator with mingw support.

Short instruction

  1. Create your plugin project from QtCreator (a shared library project), place it in directory next to the Letos.
  2. Add it to Plugins's CMakeLists.txt file
  3. Add yourplugin.json to your project and fill it with plugin's metadata information - see bottom of this page for example.
  4. For instructions on how to write plugin class for each specific plugin see tutorial for that specific plugin.

Full instructions

Create new project

The project has to be of "Shared library" type. It's directory has to be placed next to the Letos and Plugins directories (see the required directory structure).

If you want you can put your plugin into the Plugins directory as another plugin subproject. In that case you will also need to add your plugin's directory name to plugins.pro file.

Usually you will want to create a separate project, next to Plugins directory, not inside. It's easier this way for external plugins.

In the end you should have Letos, Plugins and YourPluginDir all in the same directory.

Add GUI dependency if necessary

This step is required only if your plugin is going to use anything from GUI client of Letos, that is anything from Letos/gui directory. This is for example when you want to add some elements to the UI (buttons, menus, etc), or you want to use any symbols from GUI project, like functions from uiutils.h.

To enable GUI dependency for plugin, you have to add:

"gui": true

to your plugin's json file (see bottom of this page for more details on json file).

If you don't do that, Letos will be trying to load GUI plugin even the CLI was started by the user and plugin will fail to load. While this is not a critical failure (plugin will just not load in CLI), it's still better to let Letos know, that this is a GUI plugin in json file.

Remove redundant statements

You can remove following (or similar) statement from the "pro" file:

unix:!symbian {
 maemo5 {
 target.path = /opt/usr/lib
 } else {
 target.path = /usr/lib
 }
 INSTALLS += target
}

The necessary statements are already covered by the "plugins.pri" file included earlier. The one above would only cause warnings from the qmake.

Plugin class

The main plugin's class (the one that the QtCreator created by default for you) should have following declaration:

class YOURPLUGINSHARED_EXPORT YourPluginExport : public GenericPlugin, public GeneralPurposePlugin
{
 Q_OBJECT
 LETOS_PLUGIN("yourplugin.json")
 // ...
};

You can read about GenericPlugin here. The GeneralPurposePlugin is an interface class that your plugin will implement. You can pick other type, depending on the kind of plugin you want to implement. This is also a name of plugin type that you will put into Plugin's json file (see below).

The LETOS_PLUGIN macro is mandatory. It provides all necessary declarations for the class to become a valid Letos plugin. It has a single argument, which is a name of the json file (see below). If the json file is in any subdirectory, provide a relative path to the file as an argument to this macro.

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /