Results 1 to 5 of 5

Thread: QGraphicsView::translate

  1. #1
    Join Date
    Mar 2008
    Location
    Morocco
    Posts
    47
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QGraphicsView::translate

    Hi..
    I Have a trouble to choose the right values for the QGraphicsView::translte method..
    My graphicsView contains a map ..and I disabled the scrollBar which is generated automaticly by the class..inseatd I wanna use some Actions To allow a translate right,left,up and down..

    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::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);
    }


    ..sometime it works with the pan right but the othrs are still inactive?!!

    Plz if someOne had used that method befor could help !!
    thanks

  2. #2
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QGraphicsView::translate

    Could you paste your code, or at least a piece of it? Thanks

    kacper
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  3. #3
    Join Date
    Mar 2008
    Location
    Morocco
    Posts
    47
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 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:own(){
    graphicsView->translate(0,-1.5);
    }
    ....

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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.

  5. #5
    Join Date
    Mar 2008
    Location
    Morocco
    Posts
    47
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 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() !!!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.