Results 1 to 4 of 4

Thread: QGraphicsView pan

  1. #1
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default QGraphicsView pan

    Hello,
    Any idea how to pan viewport regardless of scene size?

    What I want is to pan around scene ignoring scene "size". So that way I could pan for example to left few hundreds unit.

    Regards

    PS: What I want to achieve is similar to the functionality of setDragMode(ScrollHandDrag); but with arbitrary view transformation (scene rect smaller then view one).
    Last edited by Talei; 6th April 2014 at 07:01.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsView pan

    Doesn't QGraphicsView::translate() do that?

    Cheers,
    _

  3. #3
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QGraphicsView pan

    I'm already using translate and no it does not do what I want.

    With translate it moves scene inside sceneRect().
    Scene do expand when new items are created to accommodate them, but what I want is to move in "infinite scape" so the sceneRect() is not taken into accound while moving in pan mode.

    Example:
    Scene rect is i.e. 800x800 I do pan to position -1600 units and create item. Item is created on mouse position with will be offset by pan position, i.e. -1600 + mapToScene(cursorpos).
    But now I cant move with translate to -1600 units.

    Another problem is that I do define size of the scene to view rect, because without this when I do create item near edge then scene center moves to item center.

    So bottom line is that I would like to freely pan around scene ignoring scene size and when item is created scene size is of course resized.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  4. #4
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QGraphicsView pan

    Something that is puzzling me is this:
    when newly created scene is put on view sceneRect is 0 and View display (in default case) white background and user can create object anywhere on that 0,0 scene.

    I'm looking how it's done in that case.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

Similar Threads

  1. How to use QGraphicsView?
    By xleniz in forum Qt Programming
    Replies: 1
    Last Post: 7th June 2012, 20:10
  2. Replies: 7
    Last Post: 1st December 2011, 16:24
  3. QGraphicsView transparent over another QGraphicsView
    By evergreen in forum Qt Programming
    Replies: 0
    Last Post: 30th May 2011, 10:22
  4. Replies: 0
    Last Post: 10th January 2011, 09:42
  5. QGraphicsView
    By Yayati.Ekbote in forum Newbie
    Replies: 2
    Last Post: 4th March 2010, 15:10

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.