Hello all,

Please consider the following mock-up of how my application works:
Qt Code:
  1. class DataSource
  2. {
  3. public:
  4. QVariant dataForKey(const QString &key);
  5. };
  6.  
  7.  
  8. class BaseWidget : public QWidget
  9. {
  10. Q_OBJECT
  11. public:
  12. BaseWidget(QWidget* parent);
  13. void setDataSource(DataSource* ds) { this->ds = ds; }
  14. virtual void draw(QPainter* painter) = 0;
  15. protected:
  16. DataSource* ds;
  17. };
  18.  
  19. class SomeWidget : public BaseWidget
  20. {
  21. public:
  22. virtual void draw(QPainter* painter)
  23. {
  24. // do some custom drawing using ds->dataForKey()
  25. // with specific "key" parameter
  26. }
  27. };
To copy to clipboard, switch view to plain text mode 

My application has a repertoire of subclasses of BaseWidget that I would like to dynamically extend through plugins. Qt's documentation is quite clear on the basics, but covers only the case where the plugin can be implemented exclusively with pure Qt facilities. In this case, I would like the plug-in to be able to access my custom facilities, i.e. the DataSource mechanism in the mock-up above.

I'm not sure how to proceed toward the implementation of such a setup. How can I provide the plugins with access to facilities sitting in the main application? Should I put these facilities in a separate dynamic library against which both the application and the plugins will be linked? Or is there a potentially simpler way to achieve this?

Thanks in advance for your help,
Antoine