开发者

What is the rationale behind UI namespace in Qt?

开发者 https://www.devze.com 2022-12-12 19:48 出处:网络
In the process of creating a user interface code from UI file Qt creates 2 classes with just the same definition.

In the process of creating a user interface code from UI file Qt creates 2 classes with just the same definition.

class UI_CustomeUIClassFromUIFile
{
//code generated from UI file thru UIC
}
namespace ui
{
class CustomeUIClassFromUIFile public : UI_CustomeUIClassFromUIFi开发者_JAVA技巧le{};
}using namespace ui;

What is the reason for having 2 classes with just one inside UI namespace and other without namspace? Is it to support compiler that has no support for namespace, there is also a macro some thing like QTNAMESPACE.


The macro is QT_BEGIN_NAMESPACE which is what is used if you compiled Qt to be inside of a custom namespace.

As for the 2 classes, I think you answered it your self. You can either use Ui_XXX or Ui::XXX. I always prefer the Ui:: method, but to each their own.

So I guess I don't have a real answer as to the rationale other than letting the programmer choose.


qt/trolltech (& now nokia) published a great doclet on API design which talks about best practice for APIs. There might be an explanation for this there.

0

精彩评论

暂无评论...
验证码 换一张
取 消