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. Access class returned by QGenericPlugin::create

Access class returned by QGenericPlugin::create

Scheduled Pinned Locked Moved Unsolved General and Desktop
plugin
2 Posts 2 Posters 854 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.
  • VagabondV Offline
    VagabondV Offline
    Vagabond
    wrote on last edited by
    #1

    Hi All,

    I am just getting familiar with the Qt plugin architecture. Currently I am checking out the tuiotouch plugin, which receives UDP packets and parses out tuio protocol messages to forward tracked data into the applictaion as touch events. I was able to get it all up and running, but I was wondering if it is possible to access the data maintained by the plugin itself.

    I looked into the plugin source and noticed that the QTuioTouchPlugin returns a QTuioHandler when QTuioTouchPlugin::create(...) is called. Here is the code copied from C:\Qt\5.8\Src\qtbase\src\plugins\generic\tuiotouch\main.cpp:

    #include <QtGui/qgenericplugin.h>
    #include <QCoreApplication>
    
    #include "qtuiohandler_p.h"
    
    QT_BEGIN_NAMESPACE
    
    class QTuioTouchPlugin : public QGenericPlugin
    {
        Q_OBJECT
        Q_PLUGIN_METADATA(IID QGenericPluginFactoryInterface_iid FILE "tuiotouch.json")
    
    public:
        QTuioTouchPlugin();
    
        QObject* create(const QString &key, const QString &specification);
    };
    
    QTuioTouchPlugin::QTuioTouchPlugin()
    {
    }
    
    QObject* QTuioTouchPlugin::create(const QString &key,
                                             const QString &spec)
    {
        if (!key.compare(QLatin1String("TuioTouch"), Qt::CaseInsensitive))
            return new QTuioHandler(spec);
    
        return 0;
    }
    
    QT_END_NAMESPACE
    

    Using the QPluginLoader class I am loading the tuiotouch dll and then instaciate a QGenericPlugin from it:

    QPluginLoader loader("path/to/dll");
    QObject *plugin_obj = loader.instance();
    auto plugin = qobject_cast<QGenericPlugin*>(plugin_obj);
    

    I then proceed to create the plugin using the interface described from the plugin source main (see above):

    QObject* plugin_handle = plugin->create("TuioTouch",  "udp=3333");
    

    I want to access the class interface of QTuioHandler. Can I somehow make my compiler familiar with this QObject subclass returned by create? Can I somehow create a class header for QTuioHandler, so I can cast auto plugin_tuio_handle = qobject_cast<QTuioHandler*>(plugin_handle)?

    The plugin is compiled as a dll, so I am realizing that what I am asking might be a bit difficult to say the least.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Do you mean the qtuiohandler_p.h header file ?

      Out of curiosity, why do you want to do that?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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