Ui 表单:添加运行时还是编译时? [英] Ui forms: Add runtime or compile time?

查看:58
本文介绍了Ui 表单:添加运行时还是编译时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有多个 UI 表单,我想知道哪种方式更有效.在这两种情况下,我都不知道内存使用情况,我只是在一个简单的示例中尝试了两种方法.

I want to know which way is efficient if I am having number of UI forms. I don have any idea about memory utilization in both of case I just tried both ways in a simple example.

http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html 在这里他们描述了两种方式.现在哪一种方法更有效?

http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html here they described both ways. Now which one method is more efficient?

推荐答案

使用 ui 文件的首选方法是使用 uic 编译它们.QtCreator 会自动处理这个问题.如果您有特殊限制,您可以使用 QUiLoader - 例如,如果您想加载自定义 ui 而无需重新编译您的程序.

The prefered way to use ui files is to compile them with the uic. QtCreator will automatically take care of this. You can use the QUiLoader if you have special constraints - for example if you want to load a customized ui without the need to recompile your program.

就内存使用而言,您应该不会注意到任何差异.两者都实例化相同的类.当然,在编译或运行时需要时间来读取/解析/生成代码.我会说,在普通应用程序中,这是相当微不足道的,因为需要用户交互来更改应用程序的形式,但我从未对此进行过基准测试.

In terms of memory usage you should not notice any difference. Both instanciate the same classes. Of course the time to read/parse/generate code is needed at compile or at runtime. I would say that in a normal application this is rather insignificant since a user interaction is needed to change the form of a application, but I have never benchmarked this.

这篇关于Ui 表单:添加运行时还是编译时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆