Results 1 to 7 of 7

Thread: graphicsView.fitInView() :- one axis only ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2011
    Posts
    5
    Qt products
    Platforms
    Windows

    Default Re: graphicsView.fitInView() :- one axis only ?

    I got it

    Qt Code:
    1. def resize():
    2. width=ui.graphicsView.frameRect().width()
    3. rr=ui.graphicsView.mapToScene(ui.graphicsView.frameRect())
    4. ui.graphicsView.fitInView(0,0,width,300)
    5. ui.graphicsView.ensureVisible(rr.boundingRect(),-2,0)
    To copy to clipboard, switch view to plain text mode 

    only have to figure out why it wont initiate properly when first run, any ideas ?
    Thx all.

    Windows XPpSP3|Python 2.7.1|Qt 4.7.1|PyQt 4.8.3|sip 4.12.1|QScintilla 2.4.6

  2. #2
    Join Date
    Apr 2010
    Posts
    769
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    1
    Thanked 94 Times in 86 Posts

    Default Re: graphicsView.fitInView() :- one axis only ?

    If you're asking for the sizes of components in the constructor, that can cause problems. Components don't have a definite size until they're completely constructed. You'll want to do your resizing after the constructor has finished.

    QWidget::ensurePolished() may be helpful here, but a separate function called after construction works.

  3. #3
    Join Date
    Feb 2011
    Posts
    5
    Qt products
    Platforms
    Windows

    Default Re: graphicsView.fitInView() :- one axis only ?

    hmm i kinda suspected something like that but iv tried calling the resize() at the last possible point (just before the app loop) but that didn't work.

    So whats ensurePolished for then, i shall go have a look

    thx.
    Thx all.

    Windows XPpSP3|Python 2.7.1|Qt 4.7.1|PyQt 4.8.3|sip 4.12.1|QScintilla 2.4.6

Similar Threads

  1. Replies: 0
    Last Post: 9th August 2010, 11:46
  2. QGraphicsView::fitInView() problem on Windows
    By nileshsince1980 in forum Qt Programming
    Replies: 1
    Last Post: 18th November 2009, 05:52
  3. How to don't fitInView a QGraphicsItem
    By jano_alex_es in forum Newbie
    Replies: 2
    Last Post: 26th October 2009, 15:52
  4. fitInView problem at QGraphicsView
    By oguzy in forum Qt Programming
    Replies: 1
    Last Post: 21st November 2008, 00:36
  5. graphics view FitInView problem
    By aamer4yu in forum Qt Programming
    Replies: 6
    Last Post: 25th January 2007, 11:24

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.