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
{
Q_OBJECT
public:
~MainWin();
private:
Ui::MainWin *ui;//a member value
};
//Use it as a member
class MainWin : public QMainWindow
{
Q_OBJECT
public:
MainWin(QWidget *parent = 0);
~MainWin();
private:
Ui::MainWin *ui;//a member value
};
To copy to clipboard, switch view to plain text mode
//Inherit as a base class
class MainWin
: public QMainWindow,
public UI
::MainWin//Multiple inheritance{
Q_OBJECT
public:
~MainWin();
};
//Inherit as a base class
class MainWin : public QMainWindow,public UI::MainWin//Multiple inheritance
{
Q_OBJECT
public:
MainWin(QWidget *parent = 0);
~MainWin();
};
To copy to clipboard, switch view to plain text mode
"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?
Bookmarks