Results 1 to 1 of 1

Thread: how to call a screen plugin function directy

  1. #1
    Join Date
    Oct 2010
    Posts
    14
    Qt products
    Qt4 Qt/Embedded

    Default how to call a screen plugin function directy

    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:

    Qt Code:
    1. class MyInterface
    2. {
    3. public:
    4. virtual ~MyInterface() {}
    5. virtual void specialRefresh()= 0;
    6. };
    7.  
    8. Q_DECLARE_INTERFACE(MyInterface, "myApplication/1.0");
    To copy to clipboard, switch view to plain text mode 

    Main plugin class

    Qt Code:
    1. class DeviceScreen : public QObject, MyInterface, public QLinuxFbScreen
    2. {
    3. blah ...
    4.  
    5. void specialRefresh()
    6. }
    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:

    Qt Code:
    1. //does not work, I think because QScreen is not derived from QObject
    2. QScreen* screen = QScreen::Instance();
    3. qobject_cast<MyInterface *>((QScreen*)screen );
    4. MyInterface-> specialRefresh()
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. //does not work, crash
    2. QPluginLoader plugin;
    3. QObject* obj = plugin.Instance();
    4. qobject_cast<MyInterface *>((obj);
    5. MyInterface-> specialRefresh()
    To copy to clipboard, switch view to plain text mode 

    Class diagram:
    Last edited by Dzha; 27th October 2010 at 17:41.

Similar Threads

  1. Replies: 1
    Last Post: 8th October 2010, 11:38
  2. Qt function call in vb.net
    By abghosh in forum Qt Programming
    Replies: 7
    Last Post: 6th March 2010, 17:00
  3. Replies: 1
    Last Post: 7th October 2009, 20:37
  4. No Matching function to call...
    By weepdoo in forum Qt Programming
    Replies: 2
    Last Post: 7th November 2008, 17:30
  5. function call
    By Walsi in forum Qt Programming
    Replies: 3
    Last Post: 12th June 2007, 09:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.