Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Architecture doubt: Plugin AND Standalone together



  • I would like to improve the conceptual architecture and modularity of my new software using Qt.

    I was thinking to develop a "main application" and a set of "plugins" (shared libraries) to expand the "main application" features.

    I already did a simple test of this:
    1- I Build a custom shared library (I'm calling this a "plugin with UI")
    2- I Build the main application that uses QPluginLoader class to load shared libraries
    3- When the main application starts, it loads dynamically all "plugins" that are located in a specific folder.
    4- All running good! It works!

    So, my doubt is that I would like to each "plugin" can run alone too...like a standalone executable application.
    I would like to "double-click" on each plugin, or call it using the Terminal/Console...pass some input arguments...and get it running without the "main application".

    If this is possible, my architecture will be based on develop each "plugin" like a "software segment" that is completely autonomous (like a executable)

    BUT, if this plugin file is located inside a "plugins folder"... When the "main application" start, it will can load it dinamically too (like a shared library).

    The feature of "load dinamicaly" is important to be able to create custom menus and internal options inside the "main application".
    And in the future, other people will develop new "plugins" to this "main application". So I can't "lock" this dynamic load feature.

    Is there any way to "mix" this two file behaviors (executable and shared library)? How to do it?


  • Lifetime Qt Champion

    Hi
    you will have to use a loader app. Shared libs cannot also be
    an executable in that sense.



  • @fem_dev have you already check the overview of plugins support in Qt?



  • @mrjj thank you...where can I find the documentation or some example of Qt "Loader App"? Could you help me?



  • Yes, @pablo-j-rogina, but in my view, I don't know if this page can help me in this question...Am'I wrong?


  • Lifetime Qt Champion

    @fem_dev
    Hi
    That would be exactly like your main app.
    However, just a much smaller app that uses
    https://doc.qt.io/qt-5/qpluginloader.html
    to start the so files with a parameter that tells them
    to be in standalone mode.



  • @mrjj I don't understand how to do it...

    In my mind, a plugin is just a single file shared library (*.dll or *.so)...So, I think that this kind of file cannot be tested itself. This dynamic library file must have a main application that loaded it using QPluginLoader. Am I right?

    So, my question is about how to create a special type of Qt Project that will output a build file that will haveboth behaviors: standalone application AND a dynamic library?

    I would like to have something like: my_plugin.extension
    And put this file inside my Main Application plugins folder...like:

    C:\Program Files\My Application\Plugins\my_plugin.extension
    

    Case 1: Load plugin as a dynamic library
    I already done this using QPluginLoader and a *.dll or *.so file...it works great!

    Case 2: Run the plugin like a standalone application
    a) If I go to the "plugins folder" and double-click the my_plugin.extension file, it will show the UI (window, button, etc..) and execute some code without the main application
    b) If I go to the Terminal/Console and call it like: .\my_plugin.extension it will show the UI too and execute some code without the main application

    Is it possible?


  • Lifetime Qt Champion

    @fem_dev
    Hi
    Case 2 is not possible with the DLL/so files alone.
    It has to be loaded via some other app using QPluginLoader/QLibrary


Log in to reply