PDA

View Full Version : Qt plugins in Visual Studio 2003



micson
13th March 2007, 18:53
Hello :)
First of all I have to say that I'm a newbie in Qt, so please forgive me lack of knowledge.:o

What I'm trying to do is to make Qt4 plugins in Visual Studio. I have no problems with typical applications, when I use vcapp template. But how (step by step) to create a plugin for my application? Even the easiest one (for i.e. Dialog window with a message)? Do I need to create another project with vclib template? Or can I use existing vcapp template with my application.
This plugin should be in a *.dll file. In my application I invoke plugin by pressing a button or menu item.

I really need help on this one :/ It's very important for me, any type of support is welcome.

jacek
13th March 2007, 20:00
Do I need to create another project with vclib template? Or can I use existing vcapp template with my application.
If you want to create a librrary, then IMO you should rather use vclib template.

stevey
14th March 2007, 04:14
First off, what sort of plugins are you creating?

To make a plugin for Qt Designer, you ultimately must create a plugin project using a .pro file with:
[code]
CONFIG += designer plugin debug_and_release
TEMPLATE = lib
[\code]
You can still build the custom designer widget in Visual C++ because it's just a dll in the end.
The actual designer plugin is separate from the component you're creating.

So, in Visual Studio implement a Qt library project.
You can test it within an 'application' project type to make sure it works as you expect.
Once all is cool, write your plugin code in a separate project (as per the QtAssistant topic of creating designer plugins), then write a .pro with the entries shown above and you're done.

Other Qt plugins tend to follow a similar pattern.


I hope this helps to clear the fog :)

Steve York

micson
14th March 2007, 19:11
Stevey - I don't use QtDesigner at all.
Hmm to try if your solution works I used the "Plug and Paint" example.
As far as I understand I need to create a vcapp template with a base application sources and the vclib with plugin code? Where should I put the dll files? In my application project folder?
I'll try to do it with some examples.

PS. Jacek - do czego to doszło zeby Polacy rozmawiali ze sobą w obcym języku :)

stevey
14th March 2007, 21:34
If you're using commercial Qt with the VS addin, then when you create a project / solution it will automatically create a folder for debug and release where all the output from the projects will go.
if you're using .pro then generating a visual studio project with qmake then you only stick vcapp in the .pro if you're creating an 'application'. Given that a plugin is not an application then you must make it a vclib (as jacek stated).

I wrote a tiffio plugin which followed the same principles as for all qt plugins.
I made a 'lib' 'plugin' project and had 2 main classes.
It comprised a main class for actually doing the tiff reading and writing, then there was another class which implemented the plugin interface and returned the tiffio class.

Steve York

jacek
14th March 2007, 21:54
Where did I make a mistake?
It looks like you are missing "LIBS += -L...-lpnp_basictools". Take a look at main.cpp --- it contains "Q_IMPORT_PLUGIN(pnp_basictools)" line, which means that basictools plugin was meant as an example of a static plugin (i.e. plugin that is linked into the executable).


Jacek - do czego to doszło zeby Polacy rozmawiali ze sobą w obcym języku :)
IV RP ;)

wysota
14th March 2007, 22:05
Jacek - do czego to doszło zeby Polacy rozmawiali ze sobą w obcym języku
IV RP ;)

I'd rather say it's because QtCentre is an international site :] Alternatively you might call it globalisation.

A w ogóle to nadal mamy III RP niezależnie od tego cokolwiek ktokolwiek innego by chciał.

jacek
14th March 2007, 22:21
niezależnie od tego cokolwiek ktokolwiek innego by chciał.
Ten ktokolwiek to pewnie też lewak :P

micson
15th March 2007, 18:03
OK looks like I finally understood hot to use static and dynamic libraries :)
Thanks for your help :)

PS. Ja juz czekam na V RP bo ta IV cos kaczkom nie wyszła :crying:

micson
16th March 2007, 19:24
Another issue :o
I'm still testing Plug & Paint example.

I build static and dynamic plugins with no problems. The dll pnp_extrafilters.dll is created and moved to plugandpaint/plugins directory. But inside thr applications only static plugin is visible. loader for dynamic plugins returns null.
Here is what I have:
http://img159.imageshack.us/img159/5851/42130706hg5.th.jpg (http://img159.imageshack.us/my.php?image=42130706hg5.jpg)
And this is what I should have:
http://img114.imageshack.us/img114/943/93939852cu7.th.jpg (http://img114.imageshack.us/my.php?image=93939852cu7.jpg)

When I force application to load the plugin (from Project settings in VS) it says that dll is invalid. But why? I didn't modify *.pro files (only change : vclib template instead od lib)