Results 1 to 3 of 3

Thread: How to re-scale or changing the size of a QGrapicsScene

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How to re-scale ocr changing the size of a QGrapicsScene

    You can't do much when to positions are that close. You only can zoom in. use a cosmetic painter that the text and circle doesn't change their size.

    EDIT: see QPen::setCosmetic().

  2. #2
    Join Date
    Jul 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to re-scale ocr changing the size of a QGrapicsScene

    Actually, I found a solution using an article that I found here at QtCentre: Smooth Panning and Zooming

    From that article I wrote:
    Qt Code:
    1. void Layout::FitNetworkInView() {
    2. //Get the rectangle of the visible area in scene coords
    3. QRectF visibleArea = mapToScene( rect() ).boundingRect();
    4.  
    5. //Get map area
    6. QRectF r = myMap->GetMapRect();
    7.  
    8. //Scale the view
    9. qreal scaleFactor = qMin( qAbs( visibleArea.width() / r.width() ), qAbs( visibleArea.height() / r.height() ) );
    10. scaleFactor *= 0.9;
    11. if ( scaleFactor > 0 ) {
    12. scale( scaleFactor, scaleFactor );
    13. } else {
    14. scale( 1.0 / scaleFactor, 1.0 / scaleFactor );
    15. }
    16. SetCenter( r.center() );
    17. }
    To copy to clipboard, switch view to plain text mode 

    Calling the function above will nicely fit my sites within the viewport.
    /Kristian

Similar Threads

  1. Replies: 4
    Last Post: 11th July 2010, 09:47
  2. Replies: 8
    Last Post: 25th April 2010, 21:19
  3. Scale size of QGraphicsItem without scaling pen width
    By Lodorot in forum Qt Programming
    Replies: 1
    Last Post: 25th May 2009, 00:18
  4. Dynamically changing QGroupBox size
    By T4ng10r in forum Qt Programming
    Replies: 5
    Last Post: 30th March 2007, 15:02
  5. changing the size of the tab width: QTabWidget
    By nikita in forum Qt Programming
    Replies: 2
    Last Post: 29th August 2006, 08:31

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