02-10-2013 01:09 PM
Hi everyone,
I'm trying to create an instance of a C++ object on a QML form. For now I did this:
Game *game = new Game();
qml->setContextProperty("game", game);
This gives me the possibility to call functions from the game class in the QML file. (for example: game.getPlayer(0); The functions is being called (so that works).
My problem now is: getting an object from that class. For example:
Player* Game::getPlayer(intplayer)
{
Player* p = _players.at(player);
return p;
}
When I call this function, it will succeed (but when I try to log the result I get nothing. For example, the function Player::getName() returns nothing).
What am I doing wrong? I think the references to the obkect, but I don't know where.
Hopefully someone can help me with this!
Thanks in advance!
Solved! Go to Solution.
02-11-2013 07:01 AM
02-12-2013 10:57 AM
Simon_hain, thanks for the reponse!
Figured that out too.
I didn't register it, thus not making it available for contacting the class types. Silly me ![]()
It's all working perfectly now, thanks!