ZERO
ZERO

Reputation: 316

Ui namespace in Qt widget projects

I have a Qt widget project called "SeasonCreator" and am wondering about the structure of a Qt widget project.

The ui_seasoncreator.h file is hidden, but when you look into it, it defines a namespace called "Ui" and in it is a declaration of a class SeasonCreator, which inherits from Ui_SeasonCreator, which is the c.

In the seasoncreator.h file, there is also a namespace called "Ui" also with a declaration of a class called "SeasonCreator". When I click to find its original declaration it leads me to the declaration of Ui::SeasonCreator in the ui_seasoncreator.h file.

What is the purpose for these namespace and classes? Do the two definitions relate?

Do any of these Ui::SeasonCreator declarations have anything to do with the custom SeasonCreator class in seasoncreator.h?

Upvotes: 0

Views: 1566

Answers (1)

Chris
Chris

Reputation: 17535

What is the purpose for these namespace and classes?

The code in ui_XXX.h is code that is automatically generated for you when you use designer to create a form. It's put into the Ui namespace.

Do the two definitions relate?

I'm assuming you're referring to something that looks like this:

namespace Ui { class SeasonCreator; }

which is a forward declaration of the class that is part of the generated code that gives your class access to the widgets in your custom form.

Do any of these Ui::SeasonCreator declarations have anything to do with the custom SeasonCreator class in seasoncreator.h?

It's what links your custom code together with the generated code. You should probably have a member variable of your custom class called Ui::SeasonCreator *ui, which is the object you use to access the generated Ui classes.

Upvotes: 3

Related Questions