title: Qt:: How to make "snake" game move automatically?
body: <p>I'm using Qt to develop a English words snake game. Now I can let it move according to my keypress. But how to let it move according to path I have calculated using A* algorithm?</p>
  
  <p>When Press a key, I set snake's move direction, then use QTimer's timeout() to control snake's movement.</p>
  
  <pre><code>connect(&amp;timer, SIGNAL(timeout()), &amp;scene, SLOT(advance()));
  </code></pre>
  
  <p>Now I want to move snake manually without KeyPress Event according to path I have calculated.
  But if I call <code>scene.advance()</code>, my snake won't move correctly.</p>
  
  <pre><code>void GameController::move_snake(int s_x, int s_y, int to_x, int to_y)
  {
      if (to_x == s_x) {
          if (to_y &gt; s_y) {
              snake-&gt;setMoveDirection(MoveDown);
              scene.advance();
          }
          else {
              snake-&gt;setMoveDirection(MoveUp);
              scene.advance();
          }
      }
      else {
          if (to_x &gt; s_x) {
              snake-&gt;setMoveDirection(MoveRight);
              scene.advance();
          }
          else {
              snake-&gt;setMoveDirection(MoveLeft);
              scene.advance();
          }
      }
  }
  </code></pre>
  
  <p>One of my ideas is to use a QEvent Cache, when I calculate a move direction, then construct a QKeyEvent and put it into cache. Does this idea can success? If it can success, how to construct such a cache and QKeyEvent manually ? If not, how to do?</p>