I am making a program with Qtcreator (using a qt designer too). I made some QSvgWidget buttons (what I wanted was a button with a scalable image). They work, but do not preserve the aspect ratio of the image (aspect ratio should be 1: 1). I could not come up with a solution for this myself, even after several hours of trying.
I tried:
QSizePolicy qsp(QSizePolicy::Preferred,QSizePolicy::Preferred);
qsp.setHeightForWidth(true);
ui->Widgetname->setSizePolicy(qsp);
But that does not work.
Some images of the problem:
Correctly:

Wrong:

I am new to Qt and coding.
What am I doing wrong?
source
share