Extending QCAD with plugins in C++

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
stefanjacobs
Newbie Member
Posts: 5
Joined: Sun Aug 09, 2015 3:34 pm

Extending QCAD with plugins in C++

Post by stefanjacobs » Thu Sep 10, 2015 12:06 am

Hi there,

I recently purchased the QCAD Pro licence with the intention to develop plugins and add-ons to extend the application.

The documentation for extending the app with scripts (ECMAScript/JavaScript) seems quite comprehensive. I completed some of the tutorials and examples without a problem.

For my project I would like to write plugins in clean C++ for I won't be using the QCAD API (or Qt). These plugins will then be called by implementing GUI actions using ECMAScript.
If a tool requires complex or CPU intensive algorithms, these could be implemented in a C++ plugin which is then called from the script - Andrew.

[Referring to this thread: https://qcad.org/rsforum/viewtopic.php?f=30&t=3039] How will this plugin be called from the script?

However, I can't seem to find a tutorial on the howto of developing C++ plugins for QCAD. At QCAD's github page [here: https://github.com/qcad/qcad/tree/maste ... mpleplugin] there is an example plugin. Where in my QCAD Pro folder structure should this code go and when is it compiled? There's also a lot of "Copy QWebView plugin from folder $QTDIR/plugins/designer here." type readmes that confuses me.

In addition to my own plugins I wish to call external C and C++ libraries from the GUI developed by another developer. For now I'll refer to this thread [here: viewtopic.php?f=30&t=2402] but since this was asked more than 2 year ago; did anything change in this regard?

Thanks.

All the best,
Stefan

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: Extending QCAD with plugins in C++

Post by andrew » Thu Sep 10, 2015 2:35 pm

The RPluginInterface is really all there is to plugin development:
https://github.com/qcad/qcad/blob/maste ... nterface.h

If your class implements this interface and you compile a plugin from it (CONFIG += plugin), you have a plugin. Put it into the ./plugins directory and QCAD will try to load it, call init, postInit, etc.

Your plugin can link in other libraries and use other resources as you see fit.

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”