[Interest] Best way to reuse forms(or ui design) in a project
Bo Thorsen
bo at fioniasoftware.dk
Mon Jun 11 10:31:07 CEST 2012
Hi Lijo,
I would use one of two different approaches:
The first is to add a QWidget as header and footer on all your forms.
Then you promote the header widget to your header class and the footer
to your footer class. You can set the extra properties by using dynamic
properties.
This way has the advantage that you don't have to do anything to make it
work. Whenever someone checks out the source code of your project, they
can just build it.
The other approach is to create a designer plugin for your total widget.
With such a plugin, you can create any amount of properties for your
header and footers, and you can see how it looks inside designer.
If you choose this one, you have to build the designer plugin in release
mode *always*, because designer won't load a debug build. (Unless your
designer is built with debug, then your plugin must be debug.) You
should create a container plugin for this class.
Choosing between those two is a matter of what kind of maintenance you
will do on the code over the years and who will do it. While it's much
more annoying to keep designer plugins, it makes the forms much easier
to work with. It creates build issues instead of designer issues.
OTOH, doing the widget promotions means the one working on the designer
files will have to know what they are doing. If you're in a small team,
this might be okay. But if the project has a lot of different people,
this is bound to fail.
Bo.
Den 11-06-2012 09:12, Lijo Antony skrev:
> I am creating 10 different forms. All of them have a common header and
> footer. Header will have the same background image but different titles
> for different forms. Footer is also similar in concept. I would like to
> make the header and footer design only once and reuse them in all the
> forms. I should be able to set some properties like title from
> individual forms(or the associated implementation class). And if I make
> some design changes(like an extra label) later in header, it should be
> reflected on individual forms.
> Also I would like to do all the ui design using QtCreator.
>
> From my understanding so far, I can think of following possible solutions.
>
> 1. Inherit from a class implementing the common form design. – I will
> not be able to use QtCreator for designing child forms.
>
> 2. Create a template with header& footer and use the template for
> creating forms. – Any later change in header design will not be
> reflected on the forms
>
> 3. Create custom widgets for header and footer. Integrate with QtCreator
> and use in individual forms. – Relatively complex and some extra overhead.
>
> Since I am new to Qt, I am not sure which is the best way to go ahead or
> there are other options(Qt way!) available. Would any one help me on
> this? Any help would be appreciated.
Bo Thorsen,
Fionia Software.
--
Expert Qt and C++ developer for hire
Contact me if you need expert Qt help
http://www.fioniasoftware.dk
More information about the Interest
mailing list