You can do it in two ways ( at least ).
1. Declare a signal in a plugin, connect application's slot to it, and emit this signal
2. You can derive your application from another interface ( say: IMainProgram ), and give the pointer to this interface to your plugin
class IMainProgram {
public:
virtual void doSmth() = 0;
};
class Plugin
{
public:
Plugin( IMainProgram * mainProgram )
: m_mainProgram( mainProgram )
{}
void foo() {
m_mainProgram->doSmth();
}
protected:
IMainProgram * m_mainProgram;
};
class MainWindow
: public QMainWindow,
public IMainProgram
{...
virtual void doSmth() {}
...
void createPlugin() {
plugin = new Plugin( this );
}
};
class IMainProgram {
public:
virtual void doSmth() = 0;
};
class Plugin
{
public:
Plugin( IMainProgram * mainProgram )
: m_mainProgram( mainProgram )
{}
void foo() {
m_mainProgram->doSmth();
}
protected:
IMainProgram * m_mainProgram;
};
class MainWindow : public QMainWindow, public IMainProgram {
...
virtual void doSmth() {}
...
void createPlugin() {
plugin = new Plugin( this );
}
};
To copy to clipboard, switch view to plain text mode
Bookmarks