a. when having selected a certain decoder, I want to be able to interact with a set of buttons and sliders on a screen, however, without
the main program having any knowledge of it (plugins, i.e. it should be possible to add decoders, without the main program having to
know on beforehand that such a decoder even exists)
See the second part of my previous post. Here I elaborate a little.
class MainWindow {
public:
void loadPlugin () {
// here you load plugin
PluginInterface *loadedPlugin = doLoad ();
// Now call defined in the interface method to create widget that contains
// buttons and sliders specific for that plugin
QWidget pluginWindow
= loadedPlugin
->createPluginWindow
();
// And add this widget to our mainwindow
// Of course you can add specific widget(say QFrame) to be the exact container for child
// widget (with plugin controls)
pluginWindow->setParent(this);
this->ui->centralLayout->addWidget (pluginWindow);
// After that you'll have plugin-specific set of controls ins widget of choice
// Let's just save pointer for subsequent deletion
this->plugWindow= pluginWindow;
};
};
class PluginInterface {
public:
// here you can return QWidget window created in designer beforehand
// It's irrelevant if you want stand-alone window or a widget being a part of the ui
// the return type is the same
// This widget will encapsulate all controls specific for the concrete plugin
return new MyPluginWindow;
};
};
class MainWindow {
public:
void loadPlugin () {
// here you load plugin
PluginInterface *loadedPlugin = doLoad ();
// Now call defined in the interface method to create widget that contains
// buttons and sliders specific for that plugin
QWidget pluginWindow = loadedPlugin->createPluginWindow ();
// And add this widget to our mainwindow
// Of course you can add specific widget(say QFrame) to be the exact container for child
// widget (with plugin controls)
pluginWindow->setParent(this);
this->ui->centralLayout->addWidget (pluginWindow);
// After that you'll have plugin-specific set of controls ins widget of choice
// Let's just save pointer for subsequent deletion
this->plugWindow= pluginWindow;
};
};
class PluginInterface {
public:
QWidget * createPluginWindow () {
// here you can return QWidget window created in designer beforehand
// It's irrelevant if you want stand-alone window or a widget being a part of the ui
// the return type is the same
// This widget will encapsulate all controls specific for the concrete plugin
return new MyPluginWindow;
};
};
To copy to clipboard, switch view to plain text mode
b. When deallocating a decoder and creating a new decoder I want to have a fresh screen with the visuals of the new decoder. Is it possible to design
a screen for such a plugin (to be embedded on a fixed location in the main screen) using the designer
As I already said, you can place QFrame or QWidget in place where you want your plugin and the add plugin widget as a child widget to it.
Deletion is quite straightforward:
class MainWindow {
public:
void cleanUp (){
// here we clean up
this->plugWindow->deleteLater ();
// and can load another plugin
this->loadPlugin ();
// After that the widget gets deleted and a new one will be added
};
};
class MainWindow {
public:
void cleanUp (){
// here we clean up
this->plugWindow->deleteLater ();
// and can load another plugin
this->loadPlugin ();
// After that the widget gets deleted and a new one will be added
};
};
To copy to clipboard, switch view to plain text mode
Bookmarks