c++ - QT: Private member instead of inheritance? What is the reason? Is this a specific concept? -


some time ago programmed gui qt designer / qt creator. question first state schematic of how general process of creating gui mentioned ide works:

  1. creating design qt designer -> .ui files
  2. the .ui files translated header files , "uibasisclass.h" (with class uibasisclass) .
  3. you create "uisubclass.h" (with class uisubclass) making 1 private member uibasisclass ui.

code within class uisubclass:

...         private:         ui::uibasisclass ui; ... 

finally create object of uisubclass in main method -> code:

...     uisubclass *mygui = new uisubclass(); ... 

where constructor of uisubclass consists among other code of:

...     ui.setupui(this);  ... 

in short: have uisubclass responsible applicational methods, has private member of uibasisclass named ui consists of design code. when create object of uisubclass private member uibasisclass ui initialized within constructor of uisubclass object of uisubclass (?). [see: pointer]

my questions now:

  1. why isn't there used inheritance in way uisubclass inherits uibasisclass? instead 1 object of uibasisclass becomes member of uisubclass.

  2. is specific advantageous concept (if yes advantages has or how named?) or "just" necessity of qt code structure?

let me know if have specify questions or if there questions.

you can private inheritance, documented in qt documentation.

the use of private member ui default because of templates used qt creator, qt not care.


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -