PDA

View Full Version : About custom widgets , a summarize about its use ....



tonnot
23rd May 2011, 11:26
I have some confused about using a custom widget plugin.

Please confirm my actual knowlegde about it.

1.- You can use the 'promote' approach. In this case, you have to include all the files used by the custom widget.

2.- You can create a dll for it, using the plugin interface.
In this case, you have allways to create the correct EXPORT code ?
If not, how to use it ?

I have my own custom widgets dll, with code for export the symbols. It works fine.
But... when I want to use example widgets I have a lot of undefined errors ?
(I'm unable to use the multipage example.... Need I to define EXPORT code ? )

A last question, Can I use the pluginloader to load custom widgets ? (or pluginloader has another mission ?)

Thanks.




Thanks

Santosh Reddy
23rd May 2011, 18:42
I have my own custom widgets dll, with code for export the symbols. It works fine.
But... when I want to use example widgets I have a lot of undefined errors ?
(I'm unable to use the multipage example.... Need I to define EXPORT code ? )


How are u using example widget?
I don't think you can use them from dll, as you need to build it that way. You can use example widget, if you include them in your project, as done in static build.

You may need to export only if dynamic linking is required.

ChrisW67
24th May 2011, 01:39
I have some confused about using a custom widget plugin.
Please confirm my actual knowlegde about it.
1.- You can use the 'promote' approach. In this case, you have to include all the files used by the custom widget.

Yes, you can use the Promote feature in Qt Designer so that the UI file generates code to use your custom widget. In Designer you have to list the file(s) that the user of the widget must #include in order to access the class declaration. When you build the code using the UI you need to ensure that the implementation of the class is found.


2.- You can create a dll for it, using the plugin interface.
In this case, you have allways to create the correct EXPORT code ?
If not, how to use it ?

If you want to be able to drag and drop your custom widget in Designer then you need to build a plugin for Designer that provides information about widget. The interface your plugin supports provides Designer with information needed to show your widget icon in the tool bar, include the correct files during build, and expose the widget properties in the editor. This is not the same thing as simply building a library containing your custom widget.


I have my own custom widgets dll, with code for export the symbols. It works fine.
But... when I want to use example widgets I have a lot of undefined errors ?
(I'm unable to use the multipage example.... Need I to define EXPORT code ? )

No information to go on here.



A last question, Can I use the pluginloader to load custom widgets ? (or pluginloader has another mission ?)

QPluginLoader is for loading libraries that implement Qt Plugin interfaces. It is designed for safe loading of pluggable implementations of given interfaces and hides much of the complexity of resolving names. Qt also does checks that the plugin contains code that matches the expectations of the main program.

QLibrary is for run-time loading of arbitrary dynamic libraries.

If you wrap your custom widget as a Qt Plugin then, yes, QPluginLoader could handle loading for you. If, for example, you had an interface defined for a ClockWidget you could implement an analog clock, digital clock, and a Klingon clock in separate plugins and switch between them at run time.