PDA

View Full Version : Any ideas on how to load a QT plug-in into your own application?



technoViking
6th January 2010, 19:13
Hi everyone.

Basically I have an application and I want the ability to add plug-ins to my program (QT plug-ins). So I want someone to be able to write a QT plug-in and my program read and integrate the plug-in into my application.


I know qt allows you to write qt plug-ins, but how would I get my application to load the QT plug-in they wrote?


Thanks

wysota
6th January 2010, 20:44
What exactly do you mean by loading Qt plugins into your own application? Qt loads its plugins automatically when Q(Core)Application object is created.

technoViking
6th January 2010, 20:57
Okay so say I have an application, I supply the users with a limited QT API to write a plug-in for my application. Once they write that qt plug-in I need a way to register that plug-in with my application so my application can use that plug-in.

So my application would have a drop down, click install plug-in, browse to the user created plug-in and load it. Once its loaded a button would appear on my application, and when they click that button their plug-in would be launched.

Thats my ultimate goal. The part i'm confused on is how I tell my application to register that plug-in and use it.

wysota
6th January 2010, 21:33
See QPluginLoader.

technoViking
6th January 2010, 23:04
thanks a ton! thats just what I needed.

I noticed it said the QPluginLoader will check to make sure the QT API's match. If i wanted to supply the user a LIMITED Qt API and I wanted to make sure they are only using the limited libraries do you know the best way to check for this? I was thinking I could search the .dll but I don't believe thats possible to search through a .dll and see which libraries they are using in the plug-in.

The reason it needs to be a limited API is to make sure they aren't writing any software that could break the system.

ChrisW67
7th January 2010, 08:07
The users have to have a more-or-less full Qt and compiler suite that matches your in order to pass the check that QPluginLoader will do (i.e. same Qt version, compiler, and interface version). The user is limited to what can be achieved inside the program core using the interfaces you expose from the main application. To lock them down don't expose things they shouldn't touch etc. It's a hard task to block every possible type of malicious intent.

Depending on the sort of thing you want users to do you might be able to use the scripting abilities of QtScript rather than have users build native code.

technoViking
7th January 2010, 09:15
Cool thanks!

I'm actually thinking about using Qt Webkit to allow people to use plug-ins. I still need to do some research but it looks like people can load plug-ins if you have a Qt Webkit using the FactoryPlugin

wysota
7th January 2010, 11:13
If you are just about plugins and don't need WebKit functionality then leave it alone, it wouldn't do you any good. QPluginLoader is all you need. And unfortunately you have to agree that your users will be able to break the software, you just can't stop them from doing that - it's just a matter of time and effort to work around protections. The only thing you can do is provide scripting support instead of compiled plugins but even then someone can hook into your application and do almost whatever he desires.