Qt World Summit: Register Today!

Move Image around a QGraphicsView

  • Hi, I'm Trying to move an Image around a QGraphicsView and I don't have any concept on how to do it, I know I have to use a QTimer, but that's all I know about it, I don't know how to make this.

    I have to move a Cat throw a Path in a maze (A Mouse too and turn per turn, but I guess learning how to move the cat I can handle how to move the mouse), I know the positions the cat is going to use to do it, but I don't know how to work between the QTimer and this Image, also I have to make some conditions in this function.
    This function have to move the cat and the mouse, and validate when they eat a food or get drunk. (Its like the main function, where everything's happen).

    "LINK TO THE IMAGE I WANT TO MOVE":http://imgur.com/tOwysOU

    The code I got at this moment, I only set the starting position of the cat.
    @void Window::start(PilaD *caminoGato,PilaD caminoRaton){

    You can Avoid this code, this is only some code that I'm using to know the current position of the cat. In my main window this code is not a comment.
    Nodo *recorGato,*recorRaton;
    recorGato = new Nodo();
    recorRaton = new Nodo();
    recorGato = caminoGato->tope;
    recorRaton = caminoRaton->tope;
    QPixmap *icon = new QPixmap(list.at(2)); //List is a string, the path of the image.
    QGraphicsPixmapItem gato = new QGraphicsPixmapItem(icon);

    Sorry I tried to read some post, but still don't figure it out how to handle this.
    Thanks for your time.

Log in to reply