jumico
6th April 2010, 03:52
What I want to happen is this. When a certain key is pressed.
QPixmap image ("path");
QGraphicsPixmapItem *pixmap = addPixmap(image);
pixmap->setRotation(x);
This works as it is but every time a key is pressed instead of rotating the current image it adds a new one rotated. So i need to be able to declare what pixmap is without adding it. I think I just need to change this line.
QGraphicsPixmapItem *pixmap = addPixmap(image);
And I could initialialy add it somewhere else.
Here is a portion of my current code.
void Scene::keyPressEvent( QKeyEvent *e )
{
QPixmap image ("path");
QGraphicsPixmapItem *pixmap = addPixmap(image);
switch ( e->key() )
{
case Qt::Key_Left:
{
pixmap->setRotation(x);
break;
}
QPixmap image ("path");
QGraphicsPixmapItem *pixmap = addPixmap(image);
pixmap->setRotation(x);
This works as it is but every time a key is pressed instead of rotating the current image it adds a new one rotated. So i need to be able to declare what pixmap is without adding it. I think I just need to change this line.
QGraphicsPixmapItem *pixmap = addPixmap(image);
And I could initialialy add it somewhere else.
Here is a portion of my current code.
void Scene::keyPressEvent( QKeyEvent *e )
{
QPixmap image ("path");
QGraphicsPixmapItem *pixmap = addPixmap(image);
switch ( e->key() )
{
case Qt::Key_Left:
{
pixmap->setRotation(x);
break;
}