Home > Mobile >  QT child window controls how to access the main window?
QT child window controls how to access the main window?

Time:11-23

QT child window controls how to access the main window?

CodePudding user response:

Through child window parentWidget () to get the pointer to the parent window, and then do a casting can be visited, or to the parent pass through signal channel, also can use the singleton pattern in the main window, also can adjust the class structure, to avoid the problem

CodePudding user response:

This way is not recommended, so bring the reliance of the parent window and child window two-way, formed the bad architecture, after your parent window changes, will affect the child window and its coupling, it is recommended to use signal to notify the parent window do,

CodePudding user response:

1. Subclasses contained in the parent class as a data member
2. Subclasses to become a friend of the parent
3. Signal channel

CodePudding user response:

Recommend the use of signal channel mechanism, simple and convenient,

CodePudding user response:

Suggest using signals and slots
  •  Tags:  
  • Qt
  • Related