Important: Please read the Qt Code of Conduct -

Ui Namespace

  • Are these two namespaces the same? The Ui namespace in Mainwindow.h and Ui_Mainwindow.h.

    If not how does the compiler know that MainWindow in the namespace Ui in MainWindow.h is actually a forward declaration of Ui::MainWindow in Ui_Mainwindow.h

    In MainWindow.h
    namespace Ui {
    class MainWindow; //Forward declaration of MainWindow from ui_MainWindow.h

    In ui_MainWindow.h
    namespace Ui {
    class MainWindow: public Ui_MainWindow {};
    } // namespace Ui

  • Yes, Ui namespace is the same in both files if the files are in the same project.

  • Okay thank you. I know how namespaces work. Just got a bit confused since this is the first time I have used Designer to create a new Form for me.

Log in to reply