[Qt-interest] Very simple question regarding QUiLoader

Girish Ramakrishnan girish at forwardbias.in
Thu Jun 4 08:20:34 CEST 2009


Patric wrote:
> Hello,
> my question is simple. When to use QUiLoader.
> I think that the only difference is that at compile time, there'll not
> be the need of constructing the ui class (the class with the setupUi
> method). This is delayed for runtime.

Correct.

> I saw the examples for QUiLoader, I think they can be done without it
> also. If I have two forms and I want to change them in a UI, instead of
> loading them into widgets at runtime I always can just call
> "widget2.show()" instead of widget1.show().

That's correct too.

> But I may be wrong. Sorry if my question is too simple or something, I'm
> just wondering.


The loader is useful only if you want to build forms at run-time. You
can use it if you want to load/save forms at run-time. Example: Your
program allows an user to create a "custom report" where he can move
widgets around. In that case, you can just serialize the form to xml
(.ui) and store it in the database. To get it back, you read it from the
database and load it using QtUiLoader. Another use case is for
theming/styling where the layout of the widget in your program is very
different in various themes. The loader is not very useful for static forms.

You can look for more usage at
http://www.google.com/codesearch?q=QtUiTools&hl=en&btnG=Search+Code.

Girish



More information about the Qt-interest-old mailing list