View Full Version : Custom widgets, where must I put them ?

21st October 2010, 15:52
I have read the tutorials (and the book - QT Gui ) about it, but in both cases (promote and plugin) I dont know where physically must I put them.
Must I compile them ? Can I ?
Any deep tutorial or solution ?

21st October 2010, 16:22
You don't have to put them in any specific place.
You project needs to know where to find them.
You need to compile any code to have it run. (C++)
Maybe it will be easier if you first say what it is you are trying to do, and where you got it to trouble while trying.

21st October 2010, 16:48
From the book c++ gui ...
Integrating Custom Widgets with Qt Designer
Before we can use custom widgets in Qt Designer, we must make Qt Designer aware of them. There are two
techniques for doing this: the "promotion" approach and the plugin approach.
If I have a widget (h and cpp files) or somebody gives me this two files, how can I do this 'promotion'.
And If I develop one special widget and want to distribute the 'exe' or 'dll' not the code, how can I do it ?


21st October 2010, 20:29
Promoting is pretty easy. Just add the custom widget code to your Qt project. Then in the desinger, add a widget that your custom widget directly inheirits. Right-click that widget and select Promote to.. Then fill out the fields with the required header and object name for your cutom widget.

To distrubute your stuff w/o source you'll need to:

A. Distribute only to a machine that has the Qt libs
B. Distribute the shared libs that your widget needs to run with the .exe or dll
C. Build an all inclusive package by linking your code with the static version of Qt libs

22nd October 2010, 08:56
just to make it clear:
promoting a widget in designer, will not let you use its features.
Its nothing more than a way to tell designer which header it should include in the ui.
If you want to be able to add a "real" custom widget, like you can add the widget supplied with designer, you will have to write a plugin.

Having said that, I would recommend to you to leave the designer integration until you get comfortable with creating custom widgets in general.
(from your questions it looks like you are very much a beginner to C++ and Qt).
Learn first how to subclass a widget, and customize it, and use it in code.
The next step is to wrap the custom widget in a plugin or promote it in designer.