Qt C + + namespace __c++

Source: Internet
Author: User

For a custom method of naming nulls, see reference [1] for the macros Qt_begin_namespace and Qt_ in the ui_xxx.h generated by the Qt Creator based on the *.ui file for the definition of eng_namespace, see reference [3]. The following resolves the meaning of the following content in the Ui_xxx.h file:

Namespace UI {
    class mainwindow:public Ui_mainwindow {};
}//Namespace UI
It is in the namespace of Qt_namespace that defines a child namespace in which a class MainWindow is defined, the class public inherits from the Ui_mainwindow, and the MainWindow itself does not define a new member.

As you can see from the above parsing, there is no direct definition of the Ui_mainwindow object in the MainWindow.cpp file, but instead the object that defines the MainWindow class in the UI namespace!

Also, because the Ui_xxx.h file is contained by other source files, it does not include the header file directly in the MainWindow.cpp, avoiding the longer compile time. Instead, in the MainWindow.cpp file, a namespace is redefined and the Ui::mainwindow is declared in this namespace, as shown in the following code:

Namespace Ui {
class MainWindow;
}

reference materials

[1] C + + base accumulation (1) using namespace Potter custom namespaces and using

[2] QT has a name conflict with other libraries

[3] Qt_begin_namespace, Qt_end_namespace and other problems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.