Re: QGraphicsView::translate
Could you paste your code, or at least a piece of it? Thanks
kacper
Re: QGraphicsView::translate
class gpsinterface : public QMainWindow , private Ui::gpsinterface
{
Q_OBJECT
public:
gpsinterface(QWidget *parent = 0);
private slots:
void Left();
void Right();
void Up();
void Down();
void ZoomIn();
void ZoomOut();
private:
QGraphicsScene *scene;
};
//**********************file.cpp******************** ************
gpsinterface::gpsinterface(QWidget *parent) : QMainWindow(parent){
setupUi(this);
scene=new QGraphicsScene;
QPixmap image(//path..);
QGraphicsPixmapItem mypixmap(image);
scene->addItem(&mypixmap);
graphicsView->setScene(scene);
graphicsView->show();
scene->setBackgroundBrush(image);
mypixmap.show();
graphicsView->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
graphicsView->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
connect(actionZoom_in,SIGNAL(triggered()),this,SLO T(ZoomIn()));
connect(actionZoom_out,SIGNAL(triggered()),this,SL OT(ZoomOut()));
connect(actionPan_right,SIGNAL(triggered()),this,S LOT(Right()));
connect(actionPan_left,SIGNAL(triggered()),this,SL OT(Left()));
connect(actionPan_up,SIGNAL(triggered()),this,SLOT (Up()));
connect(actionPan_down,SIGNAL(triggered()),this,SL OT(Down()));
}
void gpsinterface::ZoomIn(){
graphicsView->scale(1.2,1.2);
}
void gpsinterface::ZoomOut(){
graphicsView->scale(1/1.2,1/1.2);
}
void gpsinterface::Right(){
graphicsView->translate(1.5,0);
}
void gpsinterface::Left(){
graphicsView->translate(-1.5,0);
}
void gpsinterface::Up(){
graphicsView->translate(0,1.5);
}
void gpsinterface::Down(){
graphicsView->translate(0,-1.5);
}
....
Re: QGraphicsView::translate
You are setting the background brush as image, and also adding the image as an item.
Now arent there 2 images on top of each other. When you translate, will the background also move ??
May be this is causing problem. Try changing the background brush and see if it works fine.
Re: QGraphicsView::translate
I set off the bacgkround..but still the same problem ..no changing.. I wonder if there is another way to do it whithout callin' translate() !!!