Results 1 to 2 of 2

Thread: QGraphicsView::fitInView() does not work after expanding the view

  1. #1
    Join Date
    Apr 2011
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QGraphicsView::fitInView() does not work after expanding the view

    Hi,
    I made a main window which has four frames (QFrame) in the grid layout. The first frame has a QGraphicsView to show an image set to QGraphicsPixmapItem.
    I tried to implement functionality to "maximize" the first frame by hiding other three frames:
    Qt Code:
    1. frame2->hide();
    2. frame3->hide();
    3. frame4->hide();
    4. view->fitInView(item, Qt::KeepAspectRatio);
    To copy to clipboard, switch view to plain text mode 
    With the code above the first frame (and the view) is expanded but the size of the image remains unchanged.

    Could someone please give me a few pointers?

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QGraphicsView::fitInView() does not work after expanding the view

    What is "item"?

    Typically, you use fitInView() in your QGraphicView's resizeEvent() handler, and you give it the scene()->sceneRect() for the first parameters.

    Calling this from anywhere else will have a one-time effect, since it won't be called after a resize unless it is in the resizeEvent handler.

Similar Threads

  1. QGraphicsView::fitInView()
    By stella1016 in forum Qt Programming
    Replies: 3
    Last Post: 30th March 2011, 18:49
  2. QGraphicsView::fitInView() problem on Windows
    By nileshsince1980 in forum Qt Programming
    Replies: 1
    Last Post: 18th November 2009, 04:52
  3. expanding tree view problem
    By joeld42 in forum Qt Programming
    Replies: 4
    Last Post: 8th May 2009, 20:52
  4. fitInView problem at QGraphicsView
    By oguzy in forum Qt Programming
    Replies: 1
    Last Post: 20th November 2008, 23:36
  5. graphics view FitInView problem
    By aamer4yu in forum Qt Programming
    Replies: 6
    Last Post: 25th January 2007, 10:24

Tags for this Thread

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.