Results 1 to 3 of 3

Thread: QSvgWidget cannot set fixed aspect ratio

  1. #1
    Join Date
    Jul 2012
    Posts
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question QSvgWidget cannot set fixed aspect ratio

    Is there a way to keep a fixed aspect ratio with QSvgWidget? I have been able to fix a QPixmap aspect ratio with

    QPixmap *ecoLeaf = new QPixmap(":/Images/eco-leaf.png");
    *ecoLeaf = ecoLeaf->scaled(60,60,Qt::KeepAspectRatio);

    I cannot seem to find something similar for QSvgWidget. Please, help!

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QSvgWidget cannot set fixed aspect ratio

    Here are some options:
    • constrain the width:height ratio of the widget so that the content is rendered in that ratio by default; or
    • derive from the QSvgWidget, reimplement paintEvent and use QSvgRenderer to paint the SVG within the limits you want.

  3. #3
    Join Date
    Jul 2012
    Posts
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QSvgWidget cannot set fixed aspect ratio

    Quote Originally Posted by ChrisW67 View Post
    Here are some options:
    • constrain the width:height ratio of the widget so that the content is rendered in that ratio by default; or
    • derive from the QSvgWidget, reimplement paintEvent and use QSvgRenderer to paint the SVG within the limits you want.
    Could you explain how I would go about contrainig the width:height ratio? I've tried using heightforwidth, but unsuccessfully. Is there a specific function I can use, or a specific function I should reimplement?

    Thank you

Similar Threads

  1. Replies: 7
    Last Post: 18th November 2016, 11:48
  2. Printing and Aspect ratio
    By cpt4 in forum Qwt
    Replies: 9
    Last Post: 30th September 2011, 14:28
  3. Replies: 2
    Last Post: 20th April 2011, 12:47
  4. How to get aspect ratio on selection with rubberBand?
    By suseway in forum Qt Programming
    Replies: 6
    Last Post: 25th October 2010, 08:29
  5. QProcess+mPlayer+Aspect Ratio
    By IGHOR in forum Qt Programming
    Replies: 0
    Last Post: 22nd March 2008, 03:14

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.