Dear All,
I have developed a application using QGraphicsScene and QGraphicPixmapItem. In the application I'm adding pixmaps on the graphic scene. Initially I'm inserting
Pixmap based on timer event for 1 seconds. On the same scene I need to insert second pixmap manually by pushbutton event. Im sharing the code here.plz help me, where I'm making mistake. I have attached output screen shot also.
ui(new Ui::SERVER)
{
ui->setupUi(this);
int x=50;
int y=50;
timer.start(1000);
//other declarations line edit, push buttons
}
void SERVER::timeout_123()
{
x=x+2;
y=y+2;
ui->graphicsView->setScene(scene);
pix1->setPos(x,y);
}
void SERVER::on_pushButton_clicked()
{
qDebug("inserting new item");
ui->graphicsView->setScene(scene);
GIpix2->setPos(650,150);
}
SERVER::SERVER(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::SERVER)
{
ui->setupUi(this);
scene=new QGraphicsScene(0,0,740,400);
scene=new QGraphicsScene(ui->graphicsView);
int x=50;
int y=50;
timer.start(1000);
//other declarations line edit, push buttons
}
void SERVER::timeout_123()
{
x=x+2;
y=y+2;
QPixmap pix(":/t23_1.png");
QGraphicsPixmapItem *pix1= scene->addPixmap(pix);
ui->graphicsView->setScene(scene);
pix1->setPos(x,y);
}
void SERVER::on_pushButton_clicked()
{
qDebug("inserting new item");
QPixmap pix2(":/pin30_red.png");
QGraphicsPixmapItem *GIpix2= scene->addPixmap(pix2);
ui->graphicsView->setScene(scene);
GIpix2->setPos(650,150);
}
To copy to clipboard, switch view to plain text mode
If i compile this code, initial timer based pixmap and pushbutton clicked pixmap will loaded onto the scene. In the Timer event Im incrementing setPos coordinated by 2 for every 1 second. Here on the scene, timer based pixmap is getting shifting in position but clear movement of image is not there somewat blurred.Any problem in the decalration?
Thanks in Advance.
Bookmarks