View Full Version : QSvgWidget cannot set fixed aspect ratio
gnetscher
5th August 2012, 22:20
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!
ChrisW67
6th August 2012, 04:51
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.
gnetscher
6th August 2012, 14:51
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
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.