Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]Qt Plugin framework, extend with C++
QtWS25 Last Chance

[SOLVED]Qt Plugin framework, extend with C++

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jake007
    wrote on last edited by
    #1

    Hi!

    I'm looking over plugin framework, and searching for a way how can I extend a program with plugins written in C++ with "full" control over a program ( simple example: add a new dialog and menu item, then execute that dialog when triggered)
    How has Qt Creator implemented it's functionality with plugins?
    I googled around and looked "here":http://doc.qt.digia.com/qt/plugins-howto.html , but I didn't found what I was looking for.

    Can someone point me in the right direction.

    Regards,
    Jake


    Code is poetry

    1 Reply Last reply
    0
    • M Offline
      M Offline
      marsupial
      wrote on last edited by
      #2

      Hey,
      actually, the link you posted contains some useful information - but you need to look in the section "The Lower-Level API: Extending Qt Applications".

      Now, when working with plugins, Qt 5 brings some cleaned up interface, so I recommend using that, but if you can't, it works almost the same in Qt 4, just some different macros.

      What you should look at is this example, which implements a plugin interface:
      "http://qt-project.org/doc/qt-5.0/qtwidgets/tools-plugandpaint.html":http://qt-project.org/doc/qt-5.0/qtwidgets/tools-plugandpaint.html

      However, with this aproach you're not giving full control over your application to your plugins, because your plugins can only use classes that are provided by some form of shared library - and the interface class of course.
      For example, you can use all of Qt's functions and classes, because both, your application and your plugin, will be linked against the Qt library.
      However, your custom classes, like your MainWindow, are not provided by any shared library but only available your executable.
      To enable your plugin to access those classes, I think (and I'm not entirely sure about this, but this was the only way I was able to achieve something like that) you have to outsource the entire application logic into a shared library and link your plugins against it.

      That may sound complicated, but it actually is not at all - just compile your classes into a library and your actual programm will only contain the main function which creates an instance of your main window (and uses the library itself). Then your plugins can link against those libraries.

      What you could also do is create a set of abstract classes and provide those as library, but if you truly wann FULL control, I guess you have to go with the approach described above.

      PS: I guess most of the times, you don't need/want to give your plugins full control over your application but only provide a subset of functions, so you should consider what way makes more sense...

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jake007
        wrote on last edited by
        #3

        Hi!

        Thanks for clearing things up.
        Currently I'm still on Qt 4.8.3 because I need MinGW compiler ( to lazy to find replacement for unistd.h which VS does not support). But I'm porting to Qt 5.

        Full control of course is not an option. I did not find suitable words to express myself what I want.

        I'm currently still planing how I'll implement everything so that there wont be any problems with extensibility. Overall, I solved a lot of problems with some basic logic with combination of XML and Lua ( not QtLua).

        Thanks!
        Marked as solved.

        Regards,
        Jake


        Code is poetry

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved