I have a screen plugin derived from QScreenDriverPlugin. It returns an object of QScreen* when the create() function is called. The main class in the plugin is derived from QLinuxFbScreen, which is derived from QScreen.
The plugin works perfectly well with the Qt painting system. So painting works ok by using QPainter calls from paintEvent.
Now, the problem is that device requires a special kind of screen refresh to be performed under certain circumstances. The main app knows when to trigger it and the plugin knows how to perform it. I created a function specialRefresh() in the plugin. How can I call it from my app?
In the plugin:
class MyInterface
{
public:
virtual ~MyInterface() {}
virtual void specialRefresh()= 0;
};
Q_DECLARE_INTERFACE(MyInterface, "myApplication/1.0");
class MyInterface
{
public:
virtual ~MyInterface() {}
virtual void specialRefresh()= 0;
};
Q_DECLARE_INTERFACE(MyInterface, "myApplication/1.0");
To copy to clipboard, switch view to plain text mode
Main plugin class
class DeviceScreen
: public QObject, MyInterface,
public QLinuxFbScreen
{
blah ...
void specialRefresh()
}
class DeviceScreen : public QObject, MyInterface, public QLinuxFbScreen
{
blah ...
void specialRefresh()
}
To copy to clipboard, switch view to plain text mode
The plugin is loaded automatically at the startup and specified by environment variable. Therefore I do not need to load it, but somehow I need to find MyInterface and call specialRefresh(). I have tried so far:
//does not work, I think because QScreen is not derived from QObject
qobject_cast<MyInterface
*>
((QScreen*)screen
);
MyInterface-> specialRefresh()
//does not work, I think because QScreen is not derived from QObject
QScreen* screen = QScreen::Instance();
qobject_cast<MyInterface *>((QScreen*)screen );
MyInterface-> specialRefresh()
To copy to clipboard, switch view to plain text mode
//does not work, crash
qobject_cast<MyInterface *>((obj);
MyInterface-> specialRefresh()
//does not work, crash
QPluginLoader plugin;
QObject* obj = plugin.Instance();
qobject_cast<MyInterface *>((obj);
MyInterface-> specialRefresh()
To copy to clipboard, switch view to plain text mode
Class diagram:
Bookmarks