reduce a button

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
pietro_72_
Full Member
Posts: 81
Joined: Fri Apr 17, 2015 6:40 am
Location: http://creativitainformaticart.altervista.org

reduce a button

Post by pietro_72_ » Thu Sep 26, 2019 8:09 am

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
Attachments
Screenshot_20190926-085636_VNC Viewer.jpg
Screenshot_20190926-085636_VNC Viewer.jpg (9.01 KiB) Viewed 5697 times

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: reduce a button

Post by andrew » Mon Sep 30, 2019 9:46 am

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

pietro_72_
Full Member
Posts: 81
Joined: Fri Apr 17, 2015 6:40 am
Location: http://creativitainformaticart.altervista.org

Re: reduce a button

Post by pietro_72_ » Wed Oct 02, 2019 8:25 am

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?

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: reduce a button

Post by andrew » Wed Oct 02, 2019 6:51 pm

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.

pietro_72_
Full Member
Posts: 81
Joined: Fri Apr 17, 2015 6:40 am
Location: http://creativitainformaticart.altervista.org

Re: reduce a button

Post by pietro_72_ » Wed Oct 02, 2019 9:46 pm

ok thank you, I try to arrange myself as much as possible :D

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>
Attachments
Schermo.jpg
Schermo.jpg (164.65 KiB) Viewed 5507 times

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”