Home > Back-end >  In drawPixmap picture attached QRect cycle out of 3 images, one needs to implement mobile picture Y
In drawPixmap picture attached QRect cycle out of 3 images, one needs to implement mobile picture Y

Time:04-02

GamecarsRect=new QRect,50,50,110 (0);
//connect (this, & Widget: : mousePres_signals, this, & Widget: : myslot);
}
Void Widget: : paintEvent (QPaintEvent *)
{int x=0;
QPainter painter (this);
QPixmap pix.
Pix. Load (" E:/qt/myqt/tupian/Beijing. JPG ");
Painter. DrawPixmap (0, 0, this -> width (), and this -> height (), pix).
QVector <*> QPixmap gamecars;
QPixmap * car_1=new QPixmap (" E:/qt/myqt/tupian/1-1-1. JPG ");
QPixmap * car_2=new QPixmap (" E:/qt/myqt/tupian/1-3-1. JPG ");
QPixmap * car_3=new QPixmap (" E:/qt/myqt/tupian/1-5-1. JPG ");
Gamecars. Push_back (car_1);
Gamecars. Push_back (car_2);
Gamecars. Push_back (car_3);
for (int i=0; I {x=x + 50;
GamecarsRect -> moveLeft (x);
GamecarsRect painter. DrawPixmap (* and * gamecars [I]);
This -> update ();
}
//this -> update ();
}

Void Widget: : mousePressEvent (QMouseEvent * ev)
{int x=ev -> x ();
Int y=ev -> (y);
If (x>=50 && x <=100 && y>=50 && y <=160)
{
GamecarsRect -> moveBottom (300);
QDebug () <//emit mousePres_signals ();
}
}
  • Related