Page 1 of 1
reduce a button
Posted: Thu Sep 26, 2019 8:09 am
by pietro_72_
It is possible to decrease the width of a QPushButton, I tried with:
<property name = "geometry">
<Rect>
<Width> 21 </ width>
<Height> 21 </ height>
</ Rect>
</ Property>
but it did not work
Thank you also for the previous answer
Re: reduce a button
Posted: Mon Sep 30, 2019 9:46 am
by andrew
The button might be in a layout in which case the layout controls the button size.
You should be able to override by setting size policy to fixed:
https://doc.qt.io/qt-5/qwidget.html#siz ... e-policies
Re: reduce a button
Posted: Wed Oct 02, 2019 8:25 am
by pietro_72_
I tried that:
newIdObj3D = objectFromPath ("MainWindow :: Options :: NewIdObj3D");
//newIdObj3D.resize(21,21);
sizePolicy = QtGui.QSizePolicy (QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed);
newIdObj3D.setSizePolicy (sizePolicy);
newIdObj3D.clicked.connect (function () {presNewIdObj3D ();});
but am I probably wrong?
Re: reduce a button
Posted: Wed Oct 02, 2019 6:51 pm
by andrew
Please have a look at
PropertyEditor.js for an example to set the size policy.
Note that you can search the git repository online (for example for "QSizePolicy .js"). Or you can checkout the repository and search locally. QCAD sources contain lots of JS code with plenty of example code.
Re: reduce a button
Posted: Wed Oct 02, 2019 9:46 pm
by pietro_72_
ok thank you, I try to arrange myself as much as possible
solved this way:
<Item>
<widget class = "QPushButton" name = "NewIdObj3D">
<property name = "toolTip">
<string> Creates a new 3d shape </string>
</ Property>
<property name = "sizePolicy">
<sizepolicy hsizetype = "Maximum" vsizetype = "Fixed">
<Horstretch> 0 </ horstretch>
<Verstretch> 0 </ verstretch>
</ Sizepolicy>
</ Property>
<property name = "maximumSize">
<Size>
<Width> 21 </ width>
<Height> 16777215 </ height>
</ Size>
</ Property>
<property name = "text">
<String> + </ string>
</ Property>
</ Widget>
</ Item>