手编GUI或使用gui设计器工具 [英] Handcode GUI or use gui-designer tool

查看:268
本文介绍了手编GUI或使用gui设计器工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想听到一些关于手工编码GUI的意见,作为通常使用Java或Qt与C ++,vs使用gui设计器工具? GUI设计器工具的例子将是MFC GUI设计器,Qt设计器,Interface Builder(Apple)。

I would like to hear some opinions on hand coding your GUIs as one typically do when using Java or Qt with C++, vs using a gui-designer tool? Examples of GUI designer tools would be MFC GUI-designer, Qt designer, Interface Builder (Apple).

我曾经是手工编码的粉丝,但从最近的经验我已切换。我用手编码看到的问题是,它是相当快速和灵活的写入GUI,但一旦你需要改变一个GUI写了很久以前,这可能是非常困难的。在大面板中找到正确的元素可能很困难。

I used to be a fan of hand coding but from recent experience I have switched. The problem I have seen with hand coding is that it is fairly quick and flexible to write the GUIs but once you need to make a change to a GUI written a long time ago it can be very difficult. Finding the right element in big panel can be difficult.

第二个问题是,它使得在GUI创建和布局代码中添加大量逻辑变得太容易了。我经常不得不接管维护GUI代码,这是真的很难重用,因为它的行为混合了它的外观和混合布局和行为常常使类非常大,很难理解。

The second problem is that it makes it far too easy to add a lot of logic in the GUI creation and layout code. I have often had to take over maintenance of GUI code which is really hard to reuse because its behavior is mixed with its appearance and mixing layout and behavior often makes the class very large and difficult to understand.

使用GUI设计器工具在我的视图中强制外观和逻辑之间更清晰的分离。

Using a GUI designer tool force a much clearer separation between appearance and logic in my view.

推荐答案

我强烈建议您使用界面构建器,而不是手工编码GUI。正如在提到的问题,它是一个更清洁的分离,一旦某些东西必须编辑,它更容易。

I feel strongly that you should use an interface builder instead of hand-coding a GUI. As in the question mentioned it's a much cleaner separation and once something has to be edited it's much easier.

Qt设计器有这个功能来创建一个 .ui file 1),但我认为不使用这个功能是最好的方法,因为这创建了更多的编码,不应该存在所有。从 .ui -file创建窗口的速度问题是可以忽略的,因为该窗口只能加载一次。

The Qt Designer got this feature to create a class out of a .ui file1), but I think that not using this feature is the best way, as this creates just more coded that shouldn't exist at all. The speed issue of creating the window from a .ui-file is negligible because the window has to be loaded only once.

这是PyQt,但在C ++中可能类似:

This is PyQt, but something similar is possible in C++:

class SelectDateDialog(QDialog):
    def __init__(self):
        QDialog.__init__(self)
        uic.loadUi("resources/SelectDate.ui", self)

基本上,这和将所有的UI代码包含到 __ init __()方法中的效果相同,

Essentially this has the same effect as including all your UI-code into the __init__() method, but the UI is almost completely separated from the code.

1) .ui 文件是XML文件描述用户界面

1).ui files are XML files that describe a user interface

这篇关于手编GUI或使用gui设计器工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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