Question: I'm creating a simple game with qt 5.0.1. It's something like Warblade.
I have problem with creating waves of enemies.

```
int k;
int pos = 100;
for (k = 0; k < 5; k++)
{
    pos = 100;
    for (int i = 0; i < 9; i++)
    {
        player->spawn_in_pos(pos);
        pos += 100;
    }
    //QThread::sleep(2);
}

```

When i use sleep() function, my game just can't run. It's waiting for loop finish and then it shows.

I'm also dealing with second option:

```
QTimer * timer = new QTimer();
QObject::connect( timer, SIGNAL(timeout()), player, SLOT(spawn_in_pos(pos)) );
timer->start(450);

```

But it looks like SLOT can't get the position.

Edit:
I just did what @ddriver said, and that helped me a lot.
Now I'm getting some 'laggy' style enemies movement. 

[![enter image description here](https://i.stack.imgur.com/GN1G2.jpg)](https://i.stack.imgur.com/GN1G2.jpg)

Edit2:

I'm moving my enemies down like this:

```
setPos(x(),y()+1);

```

with that timer:

```
// connect
QTimer * timer = new QTimer(this);
connect(timer,SIGNAL(timeout()),this,SLOT(move()));
// start the timer
timer->start(10);

```

It looks like very smooth movement but probably +1 pixel down and a 10 timer is to less:((

Answer: 
I'm not sure what you are trying to achieve, but in your second option, you cannot get the position, because the timeout doesn't send it.
The signal is timeout(void) and your slot expects an parameter. I guess you lack some basic understanding of the signal/slot mechanism.
The QT Documentation is pretty neat:
<http://doc.qt.io/qt-5/signalsandslots.html>

And if you just want to create a game out of nothing, here you can find a little tutorial, how to write games in QT:
<https://www.youtube.com/watch?v=8ntEQpg7gck>
Calling sleep is going to stop the thread from processing anything, which is not what you want to do.

[Using C++ 11](https://stackoverflow.com/questions/19398438/c-qt-how-to-add-std-c11-to-the-makefile-which-is-generated-by-qmake/19398489#19398489), you can use the QTimer with a lambda function like this: -

```
int pos = 100;
int nextWaveTime = 2000; // 2 seconds per wave
for (k = 0; k < 5; k++) // 5 waves of enemies
{       
    for (int i = 0; i < 9; i++) // 9 enemies per wave
    {
        QTimer * timer = new QTimer(); 
        timer->setSingleShot(true);

        pos = pos + (100*i); // set the pos, which is captured by value, in the lambda function

        QObject::connect( timer, QTimer::timeout, [=](){
           player->spawn_in_pos(pos); 
           timer->deleteLater(); // must cleanup the timer
        });

        timer->start(450 + (k*nextWaveTime));
     } 
 }

```