What is the rationale for the UI namespace in Qt?

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

class UI_CustomeUIClassFromUIFile { //code generated from UI file thru UIC } namespace ui { class CustomeUIClassFromUIFile public : UI_CustomeUIClassFromUIFile{}; }using namespace ui; 

What is the reason for having two classes with one UI namespace and the other without namspace? Is it worth supporting a compiler that does not support a namespace, there is also a macro like QTNAMESPACE.

+4
source share
2 answers

The QT_BEGIN_NAMESPACE macro, which is used if you compiled Qt inside a user namespace .

As for the 2 classes, I think you answered yourself. You can use Ui_XXX or Ui::XXX . I always prefer the Ui:: method, but to each my own.

So, I believe that I have no real answer regarding the rationale, other than letting the programmer choose.

+1
source

qt / trolltech (and now nokia) has published an excellent API design document that talks about API best practices. There may be an explanation of this there .

+1
source

All Articles