I've tried your suggestions and I am trying to understand why it would work. I've separated the plugin and the QWidget now and my loadViewer function in the plugin (matrixViewers) returns a matrixReal instance now as shown below:
if (view_type == "Real") {
matrixReal* newViewer = new matrixReal;
newViewer->setupVUI(dbTable,dbFile);
return newViewer;
} else {
// Create a default window here which says the plugin failed to load
}
}
matrixReal* matrixViewers::loadViewer(const QString &view_type, QString dbTable, QString dbFile) {
if (view_type == "Real") {
matrixReal* newViewer = new matrixReal;
newViewer->setupVUI(dbTable,dbFile);
return newViewer;
} else {
// Create a default window here which says the plugin failed to load
}
}
To copy to clipboard, switch view to plain text mode
This makes sense but the loadViewer function is a virtual function in the interface base class. Now the question: How is the interface base class going to know anything about the matrixReal class? Isn't the main program using this interface without knowledge of the classes inside the plugin (matrixReal for example)?
The viewerInterface is shown below:
class viewerInterface {
public:
virtual ~viewerInterface() { }
};
Q_DECLARE_INTERFACE(viewerInterface,"com.software_name.app-name.viewerInterface/0.1")
class viewerInterface {
public:
virtual ~viewerInterface() { }
virtual QStringList views() const = 0;
virtual matrixReal* loadViewer(const QString &view_type, QString dbTable, QString dbFile) = 0;
};
Q_DECLARE_INTERFACE(viewerInterface,"com.software_name.app-name.viewerInterface/0.1")
To copy to clipboard, switch view to plain text mode
Is it possible to do it in this way?
Bookmarks