75543255
30th August 2009, 09:33
If you use QtCreator the UI file will be generate a UI_*.h file.
In the QtCreator they use it as a member . I think which I make is a window,not has a window.
For example:
//Use it as a member
class MainWin : public QMainWindow
{
Q_OBJECT
public:
MainWin(QWidget *parent = 0);
~MainWin();
private:
Ui::MainWin *ui;//a member value
};
//Inherit as a base class
class MainWin : public QMainWindow,public UI::MainWin//Multiple inheritance
{
Q_OBJECT
public:
MainWin(QWidget *parent = 0);
~MainWin();
};
"is a" means to inherit it as base class,
"has a"means use it as member value,
Athough two ways all can work,but I want to know which is better,what's difference between them.
Why the QtCreator use it as a member?is the way better?
In the QtCreator they use it as a member . I think which I make is a window,not has a window.
For example:
//Use it as a member
class MainWin : public QMainWindow
{
Q_OBJECT
public:
MainWin(QWidget *parent = 0);
~MainWin();
private:
Ui::MainWin *ui;//a member value
};
//Inherit as a base class
class MainWin : public QMainWindow,public UI::MainWin//Multiple inheritance
{
Q_OBJECT
public:
MainWin(QWidget *parent = 0);
~MainWin();
};
"is a" means to inherit it as base class,
"has a"means use it as member value,
Athough two ways all can work,but I want to know which is better,what's difference between them.
Why the QtCreator use it as a member?is the way better?