Results 1 to 5 of 5

Thread: Centering a Widget in Graphics View

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2009
    Posts
    5

    Default Re: Centering a Widget in Graphics View

    Unfortunately, no that doesn't work. Firstly, it seems that QGraphicsProxies don't have a "width" or "height" property, I changed it to:

    Qt Code:
    1. transform.translate(-cproxy->size().width() / 2.0, -cproxy->size().height() / 2.0);
    To copy to clipboard, switch view to plain text mode 

    and it compiles and runs, but I get the same issues.

    Any other ideas?

  2. #2
    Join Date
    Apr 2006
    Location
    Denmark / Norway
    Posts
    67
    Thanks
    3
    Thanked 12 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Centering a Widget in Graphics View

    Had som similar issues, and I ended up drawing a transparent QRect that was the way above the size of the GraphicsView, and made sure the widgets were placed within this one. That way centerOn worked like a charm.

    I do think this is by design, and not a bug...

  3. #3
    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: Centering a Widget in Graphics View

    You could try QGraphicsView::fitInView also. Not sure if it will help, but I guess so

Similar Threads

  1. Trivial graphics view framework coordination problem
    By Miihkali in forum Qt Programming
    Replies: 2
    Last Post: 24th May 2009, 08:51
  2. Graphics View Panning ,zooming
    By linuxdev in forum Qt Programming
    Replies: 3
    Last Post: 29th December 2008, 07:17
  3. Replies: 4
    Last Post: 5th August 2008, 19:55
  4. Graphics view display problem.
    By kiranraj in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2007, 07:08
  5. Adding Rectangular overlay on graphics view
    By forrestfsu in forum Qt Programming
    Replies: 10
    Last Post: 21st November 2006, 19:42

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
  •  
Qt is a trademark of The Qt Company.