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:
- creating design qt designer -> .ui files
- the .ui files translated header files , "uibasisclass.h" (with class
uibasisclass) . - you create "uisubclass.h" (with class
uisubclass) making 1 private memberuibasisclass 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:
why isn't there used inheritance in way
uisubclassinheritsuibasisclass? instead 1 object ofuibasisclassbecomes member ofuisubclass.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
Post a Comment