Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. MVC with QGraphicsScene
Forum Updated to NodeBB v4.3 + New Features

MVC with QGraphicsScene

Scheduled Pinned Locked Moved Unsolved General and Desktop
mvcqgraphicsscenegame
1 Posts 1 Posters 883 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JaffaCakes
    wrote on last edited by
    #1

    So I am trying to implement MVC for a simple game. For the purpose of this imagine a simple game with a background and sprite that moves. I think I'm almost there with MVC, just not sure exactly where to put things.

    1. Should my 'View' inherit or have as an attribute the QGraphicsScene?

    2. From my understanding the view takes user input such as key presses. It is very tempting to move my character straight away. But is the correct way to send the event to the controller and let the controller decide what to do with it and then tell the view to actually move the character?

    3. Would I be rite to say that the model would check that the player move is valid for the controller? How should this communication work? Should the controller make a method call on the model or should I use signals and slots?
      I understand than the model and view notify the controller (observer) using signals. But how does the controller ask them.

    4. Finally, does the view contain all the actual 'things' in my game such as the player/character? How should the controller tell the character to move left 32 pixels. Should the view itself have movePlayerLeft() or should I dirrectly access my character and call methods on it like view->player->moveLeft() from the controller?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved