Forums

OverviewV-Play 2 Support (Qt 5)How to access parent components methods from subcomponents › Reply To: How to access parent components methods from subcomponents

OverviewV-Play 2 Support (Qt 5)How to access parent components methods from subcomponents › Reply To: How to access parent components methods from subcomponents
#8658

Alex
V-Play Team

Hi,

property aliases come in handy for this use case. If you have e.g. something like this:

Scene {
  id: gameScene
  
  property alias entityManager: entitiyManager
  EntitiyManager {
    id: entityManager
  }

  // your other stuff

}

Then every child of this gameScene, and also their children (basically every item that has the gameScene anywhere along their hierarchy) can access the entityManager by gameScene.entityManager. This removes the need to navigate up the exact structure with lots of parent calls.

Cheers,
Alex

 

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support