QT - Visual form inheritance



  • Hi,

    I'm newbie in QT. I came from delphi IDE. I can't find solution to inherit from form. For example: In delphi project I had own TBaseForm class with controls created using designer (.dfm file, similar like .ui in QT creator). When create new form, I could select form from project and then new form had all controls from base form. Furthermore, changing controls in base form had affects in all descendants in real time. Can I do something similar in QT Creator?

    Regards



  • Unfortunately: no, not really.

    There are currently two ways to use your previously created widgets within designer:

    Create a plugin for them

    Use the widget promotion feature

    The first option is the most powerful, as it allows you to really see and manipulate your widgets inside of your form. However, it does require you to build and install plugins for all of them, and that in turn requires that you have a version of Creator that you can build these for (so, you have the same toolchain as was used to build your creator). In my case, that means re-building all of creator. It works, but it is some work to set it up. The actual plugin is mostly just filling in some boiler plate stuff.

    The second option is much easier to do, but harder to use. You can 'promote' a widget that you use in your form to really act as a placeholder for one of your custom widgets. That means that at design time, you see the place holder widget only, and you also get only that behavior. However, no re-building of Creator and programming plugins is needed.

    I'd wish there was some way to directly include a widget from a .ui file into another .ui file, but so far, there isn't.



  • This can be very convenient. Maybe it should be added to feature request?



  • Thanks for replies. I will try your tips


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.